[pypy-issue] Issue #1831: py3k: incorrect parsing of kwargname in the presence of kwonlyargs (pypy/pypy)
Martin Matusiak
issues-reply at bitbucket.org
Wed Jul 30 20:55:00 CEST 2014
New issue 1831: py3k: incorrect parsing of kwargname in the presence of kwonlyargs
https://bitbucket.org/pypy/pypy/issue/1831/py3k-incorrect-parsing-of-kwargname-in-the
Martin Matusiak:
Without kwonly:
```
#!python
(Pdb) snippet = 'def f(aaa, bbb, mmm=1, nnn=2, **kwargs): pass'
(Pdb) self.compiler.compile(snippet, '<string>', 'single', 0)
Signature(['aaa', 'bbb', 'mmm', 'nnn'], None, 'kwargs', [])
```
With kwonly:
```
#!python
(Pdb) snippet = 'def f(aaa, bbb, *, mmm=1, nnn=2, **kwargs): pass'
(Pdb) self.compiler.compile(snippet, '<string>', 'single', 0)
Signature(['aaa', 'bbb'], None, 'mmm', ['mmm', 'nnn'])
# expected: Signature(['aaa', 'bbb'], None, 'kwargs', ['mmm', 'nnn'])
```
(Here, Signature.__init__ was instrumented with:
```
#!python
print self.__repr__()
```
I was trying to write a test for it:
```
#!python
def test_kwonlyargs_signature(self):
from pypy.interpreter.pycode import cpython_code_signature
snippet = 'def f(aaa, bbb, *, mmm=1, nnn=2, **kwargs): pass'
co = self.compiler.compile(snippet, '<string>', 'single', 0)
sig = cpython_code_signature(co)
# assert sig == ....
```
...but I can't figure out why the code object returned isn't the one I'm trying to compile:
```
#!python
(Pdb) co.co_argcount
0
```
Any hints?
More information about the pypy-issue
mailing list