This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients Dustin.Oprea, docs@python, ezio.melotti, r.david.murray, rhettinger, terry.reedy
Date 2014-07-12.17:20:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405185650.49.0.202542022626.issue21928@psf.upfronthosting.co.za>
In-reply-to
Content
The docstring is correct, as this is how wraps is implemented (see Lib/functools.py#l73).
partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated) will return a partial version of update_wrapper() where only the wrapper argument is missing.  The missing argument is the function decorated with wraps().

For example, this code:

def my_decorator(f):
    @wraps(f)
    def wrapper(*args, **kwds):
        return f(*args, **kwds)
    return wrapper

is equivalent to:

def my_decorator(f):
    def wrapper(*args, **kwds):
        return f(*args, **kwds)
    wrapper = wraps(f)(wrapper)
    return wrapper

Here wraps(f) creates a partial version of update_wrapper, with only the "wrapped" argument (i.e. f) set.  When the partial object returned by wrap(f) gets called, the missing "wrapper" argument is received, thus making wraps(f)(wrapper) equivalent to:

def my_decorator(f):
    def wrapper(*args, **kwds):
        return f(*args, **kwds)
    wrapper = update_wrapper(wrapper, f)
    return wrapper


That said, I agree that the sentence you quoted is not too clear/intuitive, but the following example is quite clear, so I'm not sure it's worth to removing/rephrasing the first part.

Maybe it could say something like "This is a convenience function for invoking update_wrapper() (by using partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)) as a function decorator when defining a wrapper function." instead?
History
Date User Action Args
2014-07-12 17:20:50ezio.melottisetrecipients: + ezio.melotti, rhettinger, terry.reedy, r.david.murray, docs@python, Dustin.Oprea
2014-07-12 17:20:50ezio.melottisetmessageid: <1405185650.49.0.202542022626.issue21928@psf.upfronthosting.co.za>
2014-07-12 17:20:50ezio.melottilinkissue21928 messages
2014-07-12 17:20:49ezio.melotticreate