Show More
@@ -333,7 +333,10 b' def bind(func, *args):' | |||||
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__', {})) |
@@ -54,3 +54,11 b' with wrap1:' | |||||
54 | print('context manager', dummy.getstack()) |
|
54 | print('context manager', dummy.getstack()) | |
55 | print('context manager', dummy.getstack()) |
|
55 | print('context manager', dummy.getstack()) | |
56 | print('context manager', dummy.getstack()) |
|
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