Patch two bugs in functools.update_wrapper.
17035
def update_wrapper(wrapper,
                   wrapped,
                   assigned = functools.WRAPPER_ASSIGNMENTS,
                   updated = functools.WRAPPER_UPDATES):
    
    # workaround for http://bugs.python.org/issue3445
    assigned = tuple(attr for attr in assigned if hasattr(wrapped, attr))
    wrapper = functools.update_wrapper(wrapper, wrapped, assigned, updated)
    # workaround for https://bugs.python.org/issue17482
    wrapper.__wrapped__ = wrapped
    return wrapper
825682
def patchCurses(self):
        
        if (sys.version_info)[:3] == (3, 4, 0):
            self.addchar = lambda y, x, *args: self.win.addch(x, y, *args)
        else:
            self.addchar = self.win.addch
446636
def wraps(__fn, **kw):
        """"""
        kw['assigned'] = kw.get('assigned', WRAPPER_ASSIGNMENTS)
        return functools.wraps(__fn, **kw)
391696
def combine(self, patch):
        """"""
        exclusive = set(["config", "default", "mandatory", "presence",
                     "min-elements", "max-elements"])
        kws = set([s.keyword for s in self.plist]) & exclusive
        add = [n for n in patch.plist if n.keyword not in kws]
        self.plist.extend(add)
292630
function patch(ctx) {
    const statusMethods = Object.assign({}, opts.statusMethods, statusCodeMap)
    ctx.send = respond.bind(ctx, ctx)

    // Bind status methods.
    for (const method in statusMethods) {
      const code = statusMethods[method]
      ctx[method] = respond.bind(ctx, ctx, code)
    }

    // Bind other methods
    const methods = Object.assign({}, opts.methods)
    for (const method in methods) {
      const fn = methods[method]
      ctx[method] = fn.bind(ctx, ctx)
    }

    return ctx
  }
545291
def replace_exceptions(
    old_to_new_exceptions: Dict[Type[BaseException], Type[BaseException]]
) -> Callable[..., Any]:
    
    old_exceptions = tuple(old_to_new_exceptions.keys())

    def decorator(to_wrap: Callable[..., Any]) -> Callable[..., Any]:
        @functools.wraps(to_wrap)
        # String type b/c pypy3 throws SegmentationFault with Iterable as arg on nested fn
        # Ignore so we don't have to import `Iterable`
        def wrapper(
            *args: Iterable[Any], **kwargs: Dict[str, Any]
        ) -> Callable[..., Any]:
            try:
                return to_wrap(*args, **kwargs)
            except old_exceptions as err:
                try:
                    raise old_to_new_exceptions[type(err)] from err
                except KeyError:
                    raise TypeError(
                        "could not look up new exception to use for %r" % err
                    ) from err

        return wrapper

    return decorator
540436
def patch(*args, **kwargs):
    
    from caliendo.patch import patch as p
    return p(*args, **kwargs)
116978
def wrapper(self, updateParams=None):
		
		def decorator(f):
			_headers = self._getHeaders(updateParams)
			""" flask decorator to include headers """
			@wraps(f)
			def decorated_function(*args, **kwargs):
				resp = make_response(f(*args, **kwargs))
				self._setRespHeader(resp, _headers)
				resp.has_secure_headers = True
				return resp
			return decorated_function
		return decorator
67444
def _stamp_and_update_hook(method,  # suppress(too-many-arguments)
                           dependencies,
                           stampfile,
                           func,
                           *args,
                           **kwargs):
    """"""
    result = _stamp(stampfile, func, *args, **kwargs)
    method.update_stampfile_hook(dependencies)
    return result
1210353
def safe_wraps(wrapper, *args, **kwargs):
    """"""
    while isinstance(wrapper, functools.partial):
        wrapper = wrapper.func
    return functools.wraps(wrapper, *args, **kwargs)
941577
function patchCallbacks(target, targetName, method, callbacks) {
    var symbol = Zone.__symbol__(method);
    if (target[symbol]) {
        return;
    }
    var nativeDelegate = target[symbol] = target[method];
    target[method] = function (name, opts, options) {
        if (opts && opts.prototype) {
            callbacks.forEach(function (callback) {
                var source = targetName + "." + method + "::" + callback;
                var prototype = opts.prototype;
                if (prototype.hasOwnProperty(callback)) {
                    var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback);
                    if (descriptor && descriptor.value) {
                        descriptor.value = wrapWithCurrentZone(descriptor.value, source);
                        _redefineProperty(opts.prototype, callback, descriptor);
                    }
                    else if (prototype[callback]) {
                        prototype[callback] = wrapWithCurrentZone(prototype[callback], source);
                    }
                }
                else if (prototype[callback]) {
                    prototype[callback] = wrapWithCurrentZone(prototype[callback], source);
                }
            });
        }
        return nativeDelegate.call(target, name, opts, options);
    };
    attachOriginToPatched(target[method], nativeDelegate);
}
664913
def patch(self, patch):
        
        data = apply_patch(dict(self), patch)
        return self.__class__(data, model=self.model)
1040295
def update(self, commit=True, **kwargs):
        

        for (attr, value) in kwargs.iteritems():
            setattr(self, attr, value)
        return commit and self.save() or self
86937
def __insert_wrapper(func):
        """"""
        def check_func(self, key, new_item, instance=0):
            if key not in self.keys():
                raise KeyError("%s not a key in label" % (key))
            if not isinstance(new_item, (list, OrderedMultiDict)):
                raise TypeError("The new item must be a list or PVLModule")
            if isinstance(new_item, OrderedMultiDict):
                new_item = list(new_item)
            return func(self, key, new_item, instance)
        return check_func
139704
def patched(attrs, updates):
    """"""
    orig = patch(attrs, updates.items())
    try:
        yield orig
    finally:
        patch(attrs, orig.items())
763854
function patch(patchURI, patch, callback) {

  util.patch(patchURI, patch, function(err, res) {
    if (err) {
      callback(err)
    } else {
      callback(null, res)
    }
  })
}
397956
def _update_method(self, oldmeth, newmeth):
        """"""
        # XXX What if im_func is not a function?
        if hasattr(oldmeth, 'im_func') and hasattr(newmeth, 'im_func'):
            self._update(None, None, oldmeth.im_func, newmeth.im_func)
        elif hasattr(oldmeth, '__func__') and hasattr(newmeth, '__func__'):
            self._update(None, None, oldmeth.__func__, newmeth.__func__)
        return oldmeth