Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r88779:955d91968eb0 Date: 2016-11-30 17:09 +0100 http://bitbucket.org/pypy/pypy/changeset/955d91968eb0/
Log: Test and fix for super() with no arguments if 'self' is in a cell var diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py --- a/pypy/module/__builtin__/descriptor.py +++ b/pypy/module/__builtin__/descriptor.py @@ -76,7 +76,13 @@ raise oefmt(space.w_RuntimeError, "super(): no code object") if code.co_argcount == 0: raise oefmt(space.w_RuntimeError, "super(): no arguments") - w_obj = frame.locals_cells_stack_w[0] + args_to_copy = code._args_as_cellvars + for i in range(len(args_to_copy)): + if args_to_copy[i] == 0: + w_obj = frame._getcell(i).w_value + break + else: + w_obj = frame.locals_cells_stack_w[0] if not w_obj: raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted") diff --git a/pypy/module/__builtin__/test/test_descriptor.py b/pypy/module/__builtin__/test/test_descriptor.py --- a/pypy/module/__builtin__/test/test_descriptor.py +++ b/pypy/module/__builtin__/test/test_descriptor.py @@ -508,4 +508,11 @@ del __class__ super() raises(RuntimeError, X().f) + class X: + def f(self): + def g(): + print(self) # make 'self' a closure inside 'f' + del self + super() + raises(RuntimeError, X().f) """ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit