[pypy-commit] pypy py3.6: issue #2996: a first bug found and fixed, but there is more
arigo
pypy.commits at gmail.com
Mon Apr 22 06:23:46 EDT 2019
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.6
Changeset: r96532:363063d2f12b
Date: 2019-04-22 11:49 +0200
http://bitbucket.org/pypy/pypy/changeset/363063d2f12b/
Log: issue #2996: a first bug found and fixed, but there is more
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -58,8 +58,9 @@
assert argcount >= 0 # annotator hint
assert kwonlyargcount >= 0
argnames = list(varnames[:argcount])
- if argcount < len(varnames):
+ if kwonlyargcount > 0:
kwonlyargs = list(varnames[argcount:argcount + kwonlyargcount])
+ argcount += kwonlyargcount
else:
kwonlyargs = None
if code.co_flags & CO_VARARGS:
@@ -68,7 +69,7 @@
else:
varargname = None
if code.co_flags & CO_VARKEYWORDS:
- kwargname = code.co_varnames[argcount + kwonlyargcount]
+ kwargname = code.co_varnames[argcount]
else:
kwargname = None
return Signature(argnames, varargname, kwargname, kwonlyargs)
diff --git a/pypy/interpreter/test/test_compiler.py b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -824,6 +824,13 @@
sig = cpython_code_signature(co)
assert sig == Signature(['a', 'b'], None, 'kwargs', ['m', 'n'])
+ # a variant with varargname, which was buggy before issue2996
+ snippet = 'def f(*args, offset=42): pass'
+ containing_co = self.compiler.compile(snippet, '<string>', 'single', 0)
+ co = find_func(containing_co)
+ sig = cpython_code_signature(co)
+ assert sig == Signature([], 'args', None, ['offset'])
+
class AppTestCompiler(object):
More information about the pypy-commit
mailing list