[pypy-commit] pypy py3k: expose co_kwonlyargcount

gutworth noreply at buildbot.pypy.org
Thu Mar 15 02:40:15 CET 2012


Author: Benjamin Peterson <benjamin at python.org>
Branch: py3k
Changeset: r53636:265ccae3c0f0
Date: 2012-03-14 20:39 -0500
http://bitbucket.org/pypy/pypy/changeset/265ccae3c0f0/

Log:	expose co_kwonlyargcount

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
@@ -23,12 +23,14 @@
                            'co_names': (),
                            'co_varnames': (),
                            'co_argcount': 0,
+                           'co_kwonlyargcount': 0,
                            'co_consts': (None,)
                            }),
             (g.__code__, {'co_name': 'g',
                            'co_names': (),
                            'co_varnames': ('x', 'y', 'z'),
                            'co_argcount': 1,
+                           'co_kwonlyargcount': 0,
                            'co_consts': ("docstring", None),
                            }),
             ]
@@ -58,6 +60,12 @@
             for key, value in expected.items():
                 assert getattr(code, key) == value
 
+    def test_kwonlyargcount(self):
+        """
+        def f(*args, a, b, **kw): pass
+        assert f.__code__.co_kwonlyargcount == 2
+        """
+
     def test_co_names(self):
         src = '''if 1:
         def foo():
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -730,6 +730,7 @@
     __reduce__   = interp2app(PyCode.descr__reduce__),
     __repr__ = interp2app(PyCode.repr),
     co_argcount = interp_attrproperty('co_argcount', cls=PyCode),
+    co_kwonlyargcount = interp_attrproperty('co_kwonlyargcount', cls=PyCode),
     co_nlocals = interp_attrproperty('co_nlocals', cls=PyCode),
     co_stacksize = interp_attrproperty('co_stacksize', cls=PyCode),
     co_flags = interp_attrproperty('co_flags', cls=PyCode),


More information about the pypy-commit mailing list