1 new changeset in py:

http://bitbucket.org/hpk42/py/changeset/13912770a994/
changeset:   13912770a994
user:        hpk42
date:        2011-07-08 15:30:03
summary:     don't consider __call__ if asked for a class
affected #:  2 files (166 bytes)

--- a/py/_code/code.py  Fri Jul 08 13:22:14 2011 +0200
+++ b/py/_code/code.py  Fri Jul 08 15:30:03 2011 +0200
@@ -722,7 +722,7 @@
         obj = getattr(obj, 'f_code', obj)
         obj = getattr(obj, '__code__', obj)
         if trycall and not hasattr(obj, 'co_firstlineno'):
-            if hasattr(obj, '__call__'):
+            if hasattr(obj, '__call__') and not py.std.inspect.isclass(obj):
                 x = getrawcode(obj.__call__, trycall=False)
                 if hasattr(x, 'co_firstlineno'):
                     return x


--- a/testing/code/test_source.py       Fri Jul 08 13:22:14 2011 +0200
+++ b/testing/code/test_source.py       Fri Jul 08 15:30:03 2011 +0200
@@ -443,3 +443,8 @@
 
     code = py.code.Code(WithCall())
     assert 'pass' in str(code.source())
+
+    class Hello(object):
+        def __call__(self):
+            pass
+    py.test.raises(TypeError, lambda: py.code.Code(Hello))

Repository URL: https://bitbucket.org/hpk42/py/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to