Mercurial > public > mercurial-scm > hg
comparison mercurial/extensions.py @ 34128:82bd4c5a81e5
extensions: fix wrapcommand/function of class instance
5361771f9714 changed _updatewrapper() to copy the __name__ attribute, but
not all callable objects has __name__.
Spotted by loading mq with extdiff.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 10 Sep 2017 23:37:14 +0900 |
parents | a763c891f36e |
children | f7c9c5d8c7f4 |
comparison
equal
deleted
inserted
replaced
34127:709b44f38ab9 | 34128:82bd4c5a81e5 |
---|---|
331 return func(*(args + a), **kw) | 331 return func(*(args + a), **kw) |
332 return closure | 332 return closure |
333 | 333 |
334 def _updatewrapper(wrap, origfn, unboundwrapper): | 334 def _updatewrapper(wrap, origfn, unboundwrapper): |
335 '''Copy and add some useful attributes to wrapper''' | 335 '''Copy and add some useful attributes to wrapper''' |
336 wrap.__name__ = origfn.__name__ | 336 try: |
337 wrap.__name__ = origfn.__name__ | |
338 except AttributeError: | |
339 pass | |
337 wrap.__module__ = getattr(origfn, '__module__') | 340 wrap.__module__ = getattr(origfn, '__module__') |
338 wrap.__doc__ = getattr(origfn, '__doc__') | 341 wrap.__doc__ = getattr(origfn, '__doc__') |
339 wrap.__dict__.update(getattr(origfn, '__dict__', {})) | 342 wrap.__dict__.update(getattr(origfn, '__dict__', {})) |
340 wrap._origfunc = origfn | 343 wrap._origfunc = origfn |
341 wrap._unboundwrapper = unboundwrapper | 344 wrap._unboundwrapper = unboundwrapper |