[issue4360] SystemError when method has both super() & closure
kai zhu
report at bugs.python.org
Thu Nov 20 12:10:30 CET 2008
kai zhu <davidbranniganz at gmail.com> added the comment:
same thing, except w/ closure commented out (& everything is happy)
################################
# super_ok.py
class A(object):
def foo(self):
return super()
# comment the closure below
# & SystemError goes away
# lambda: self
A().foo()
################################
>>>
>>> s = open("super_ok.py").read()
>>> c = compile(s, "super_ok.py", "exec")
>>> t = py3to2.codetree(t)
>>> print( t )
codetree(
co_argcount = 0,
co_cellvars = (),
co_code =
b'Gd\x00\x00\x84\x00\x00d\x01\x00e\x00\x00\x83\x03\x00Z\x01\x00e\x01\x00\x83\x00\x00j\x02\x00\x83\x00\x00\x01d\x02\x00S',
co_filename = 'super_closure.py',
co_firstlineno = 3,
co_flags = 64,
co_freevars = (),
co_kwonlyargcount =0,
co_lnotab = b'\x13\x06',
co_name = '<module>',
co_names = ('object', 'A', 'foo'),
co_nlocals = 0,
co_stacksize = 4,
co_varnames = (),
depth = 0,
co_consts = (
codetree(
co_argcount = 1,
co_cellvars = ('__class__',),
co_code =
b'|\x00\x00Ee\x00\x00Z\x01\x00\x87\x00\x00f\x01\x00d\x00\x00\x86\x00\x00Z\x02\x00\x87\x00\x00S',
co_filename = 'super_closure.py',
co_firstlineno = 3,
co_flags = 2,
co_freevars = (),
co_kwonlyargcount =0,
co_lnotab = b'\n\x01',
co_name = 'A',
co_names = ('__name__', '__module__', 'foo'),
co_nlocals = 1,
co_stacksize = 2,
co_varnames = ('__locals__',),
depth = 1,
co_consts = (
codetree(
co_argcount = 1,
co_cellvars = ('self',),
co_code =
b't\x00\x00\x83\x00\x00S\x87\x00\x00f\x01\x00d\x01\x00\x86\x00\x00\x01',
co_filename = 'super_closure.py',
co_firstlineno = 4,
co_flags = 3,
co_freevars = ('__class__',),
co_kwonlyargcount =0,
co_lnotab = b'\x00\x01\x07\x03',
co_name = 'foo',
co_names = ('super',),
co_nlocals = 1,
co_stacksize = 2,
co_varnames = ('self',),
depth = 2,
co_consts = (
None,
codetree(
co_argcount = 0,
co_cellvars = (),
co_code = b'\x88\x00\x00S',
co_filename = 'super_closure.py',
co_firstlineno = 8,
co_flags = 19,
co_freevars = ('self',),
co_kwonlyargcount =0,
co_lnotab = b'',
co_name = '<lambda>',
co_names = (),
co_nlocals = 0,
co_stacksize = 1,
co_varnames = (),
depth = 3,
co_consts = (
)),
)),
)),
A,
None,
))
>>>
>>> print( t.dis() )
3 0 LOAD_BUILD_CLASS
1 LOAD_CONST 0 (<code object A at
0x2a987af2b0, file "super_closure.py", line 3>)
4 MAKE_FUNCTION 0
7 LOAD_CONST 1 ('A')
10 LOAD_NAME 0 (object)
13 CALL_FUNCTION 3
16 STORE_NAME 1 (A)
9 19 LOAD_NAME 1 (A)
22 CALL_FUNCTION 0
25 LOAD_ATTR 2 (foo)
28 CALL_FUNCTION 0
31 POP_TOP
32 LOAD_CONST 2 (None)
35 RETURN_VALUE
3 0 LOAD_FAST 0 (__locals__)
3 STORE_LOCALS
4 LOAD_NAME 0 (__name__)
7 STORE_NAME 1 (__module__)
4 10 LOAD_CLOSURE 0 (__class__)
13 BUILD_TUPLE 1
16 LOAD_CONST 0 (<code object foo at
0x2a987af4b0, file "super_closure.py", line 4>)
19 MAKE_CLOSURE 0
22 STORE_NAME 2 (foo)
25 LOAD_CLOSURE 0 (__class__)
28 RETURN_VALUE
5 0 LOAD_GLOBAL 0 (super)
3 CALL_FUNCTION 0
6 RETURN_VALUE
8 7 LOAD_CLOSURE 0 (self)
10 BUILD_TUPLE 1
13 LOAD_CONST 1 (<code object
<lambda> at 0x2a987af5b0, file "super_closure.py", line 8>)
16 MAKE_CLOSURE 0
19 POP_TOP
8 0 LOAD_DEREF 0 (self)
3 RETURN_VALUE
>>>
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4360>
_______________________________________
More information about the Python-bugs-list
mailing list