Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r73530:013ccdd884c9 Date: 2014-09-13 19:22 -0700 http://bitbucket.org/pypy/pypy/changeset/013ccdd884c9/
Log: issue1844: guard against invalid code object argcounts diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py --- a/pypy/interpreter/pycode.py +++ b/pypy/interpreter/pycode.py @@ -54,7 +54,10 @@ assert argcount >= 0 # annotator hint assert kwonlyargcount >= 0 argnames = list(varnames[:argcount]) - kwonlyargs = list(varnames[argcount:argcount + kwonlyargcount]) + if argcount < len(varnames): + kwonlyargs = list(varnames[argcount:argcount + kwonlyargcount]) + else: + kwonlyargs = None if code.co_flags & CO_VARARGS: varargname = varnames[argcount] argcount += 1 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 @@ -194,3 +194,9 @@ # CO_NESTED assert d['f'](4).__code__.co_flags & 0x10 assert d['f'].__code__.co_flags & 0x10 == 0 + + def test_issue1844(self): + import types + args = (1, 0, 1, 0, 0, b'', (), (), (), '', 'operator', 0, b'') + # previously raised a MemoryError when translated + types.CodeType(*args) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit