Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r65085:cd74547a33c5
Date: 2013-06-28 23:16 +0200
http://bitbucket.org/pypy/pypy/changeset/cd74547a33c5/

Log:    Add co_kwonlyargcount to builtin code objects. This fixes
        inspect.getfullargspec(''.join), and IDLE can display tooltips for
        builtin functions.

diff --git a/pypy/interpreter/test/test_code.py 
b/pypy/interpreter/test/test_code.py
--- a/pypy/interpreter/test/test_code.py
+++ b/pypy/interpreter/test/test_code.py
@@ -40,6 +40,7 @@
                 (abs.__code__, {'co_name': 'abs',
                                  'co_varnames': ('val',),
                                  'co_argcount': 1,
+                                 'co_kwonlyargcount': 0,
                                  'co_flags': 0,
                                  'co_consts': ("abs(number) -> 
number\n\nReturn the absolute value of the argument.",),
                                  }),
@@ -47,6 +48,7 @@
                                 {#'co_name': '__init__',   XXX getting 
descr__init__
                                  'co_varnames': ('obj', 'args', 'keywords'),
                                  'co_argcount': 1,
+                                 'co_kwonlyargcount': 0,
                                  'co_flags': 0x000C,  # VARARGS|VARKEYWORDS
                                  }),
                 ]
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -666,6 +666,9 @@
 def fget_co_argcount(space, code): # unwrapping through unwrap_spec
     return space.wrap(code.signature().num_argnames())
 
+def fget_zero(space, code):
+    return space.wrap(0)
+
 def fget_co_flags(space, code): # unwrapping through unwrap_spec
     sig = code.signature()
     flags = 0
@@ -711,6 +714,7 @@
     co_name = interp_attrproperty('co_name', cls=Code),
     co_varnames = GetSetProperty(fget_co_varnames, cls=Code),
     co_argcount = GetSetProperty(fget_co_argcount, cls=Code),
+    co_kwonlyargcount = GetSetProperty(fget_zero, cls=Code),
     co_flags = GetSetProperty(fget_co_flags, cls=Code),
     co_consts = GetSetProperty(fget_co_consts, cls=Code),
     )
@@ -721,6 +725,7 @@
     co_name = interp_attrproperty('co_name', cls=BuiltinCode),
     co_varnames = GetSetProperty(fget_co_varnames, cls=BuiltinCode),
     co_argcount = GetSetProperty(fget_co_argcount, cls=BuiltinCode),
+    co_kwonlyargcount = GetSetProperty(fget_zero, cls=BuiltinCode),
     co_flags = GetSetProperty(fget_co_flags, cls=BuiltinCode),
     co_consts = GetSetProperty(fget_co_consts, cls=BuiltinCode),
     )
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to