Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r58287:9fe4526f1973
Date: 2012-10-20 23:20 +0200
http://bitbucket.org/pypy/pypy/changeset/9fe4526f1973/

Log:    PyPy extension: inspect.getargs() works on built-in functions. Port
        the diff from 2.7.

diff --git a/lib-python/3.2/inspect.py b/lib-python/3.2/inspect.py
--- a/lib-python/3.2/inspect.py
+++ b/lib-python/3.2/inspect.py
@@ -767,7 +767,13 @@
     and 'varkw' are the names of the * and ** arguments or None."""
 
     if not iscode(co):
-        raise TypeError('{!r} is not a code object'.format(co))
+        if hasattr(len, 'func_code') and type(co) is type(len.func_code):
+            # PyPy extension: built-in function objects have a func_code too.
+            # There is no co_code on it, but co_argcount and co_varnames and
+            # co_flags are present.
+            pass
+        else:
+            raise TypeError('{!r} is not a code object'.format(co))
 
     nargs = co.co_argcount
     names = co.co_varnames
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to