Show More
@@ -333,7 +333,10 def bind(func, *args): | |||
|
333 | 333 | |
|
334 | 334 | def _updatewrapper(wrap, origfn, unboundwrapper): |
|
335 | 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 | 340 | wrap.__module__ = getattr(origfn, '__module__') |
|
338 | 341 | wrap.__doc__ = getattr(origfn, '__doc__') |
|
339 | 342 | wrap.__dict__.update(getattr(origfn, '__dict__', {})) |
@@ -54,3 +54,11 with wrap1: | |||
|
54 | 54 | print('context manager', dummy.getstack()) |
|
55 | 55 | print('context manager', dummy.getstack()) |
|
56 | 56 | print('context manager', dummy.getstack()) |
|
57 | ||
|
58 | # Wrap callable object which has no __name__ | |
|
59 | class callableobj(object): | |
|
60 | def __call__(self): | |
|
61 | return ['orig'] | |
|
62 | dummy.cobj = callableobj() | |
|
63 | extensions.wrapfunction(dummy, 'cobj', wrappers[0]) | |
|
64 | print('wrap callable object', dummy.cobj()) |
General Comments 0
You need to be logged in to leave comments.
Login now