[pypy-commit] pypy py3.5: Test and fix for super() with no arguments if 'self' is in a cell var
arigo
pypy.commits at gmail.com
Wed Nov 30 11:10:20 EST 2016
Author: Armin Rigo <arigo at 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)
"""
More information about the pypy-commit
mailing list