diff tests/test-extensions-wrapfunction.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 47e52f079a57
children ac865f020b99
line wrap: on
line diff
--- a/tests/test-extensions-wrapfunction.py	Tue Sep 12 09:13:02 2017 -0700
+++ b/tests/test-extensions-wrapfunction.py	Sun Sep 10 23:37:14 2017 +0900
@@ -54,3 +54,11 @@
         print('context manager', dummy.getstack())
     print('context manager', dummy.getstack())
 print('context manager', dummy.getstack())
+
+# Wrap callable object which has no __name__
+class callableobj(object):
+    def __call__(self):
+        return ['orig']
+dummy.cobj = callableobj()
+extensions.wrapfunction(dummy, 'cobj', wrappers[0])
+print('wrap callable object', dummy.cobj())