You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix 3.2 for/if loopback bug
problem was handling in Python 3.2 for ... if ... else: .... jump for come from if jump for In later Python 3's a "come from" is removed. Also, start to DRY parser{,2,3} grammar rules.
This commit is contained in:
BIN
test/bytecode_3.2/10_for_if_loopback.pyc
Normal file
BIN
test/bytecode_3.2/10_for_if_loopback.pyc
Normal file
Binary file not shown.
23
test/simple_source/looping/10_for_if_loopback.py
Normal file
23
test/simple_source/looping/10_for_if_loopback.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# In Python 3.2 JUMP_ABSOLUTE's (which can
|
||||
# turn into COME_FROM's) are not optimized as
|
||||
# they are in later Python's.
|
||||
#
|
||||
# So an if statement can jump to the end of a for loop
|
||||
# which in turn jump's back to the beginning of that loop.
|
||||
#
|
||||
# Should handle in Python 3.2
|
||||
#
|
||||
# 98 JUMP_BACK '16' statement after: names.append(name) to loop head
|
||||
# 101_0 COME_FROM '50' statement: if name == ...to fictional "end if"
|
||||
# 101 JUMP_BACK '16' jump as before to loop head
|
||||
|
||||
def _slotnames(cls):
|
||||
names = []
|
||||
for c in cls.__mro__:
|
||||
if "__slots__" in c.__dict__:
|
||||
slots = c.__dict__['__slots__']
|
||||
for name in slots:
|
||||
if name == "__dict__":
|
||||
continue
|
||||
else:
|
||||
names.append(name) # 3.2 bug here jumping to outer for
|
Reference in New Issue
Block a user