You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 2.6-2.7ish generator handling
This commit is contained in:
BIN
test/bytecode_2.6_run/02_ifelse_comprehension.pyc
Normal file
BIN
test/bytecode_2.6_run/02_ifelse_comprehension.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.1_run/02_ifelse_comprehension.pyc
Normal file
BIN
test/bytecode_3.1_run/02_ifelse_comprehension.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.3_run/02_ifelse_comprehension.pyc
Normal file
BIN
test/bytecode_3.3_run/02_ifelse_comprehension.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.6_run/02_ifelse_comprehension.pyc
Normal file
BIN
test/bytecode_3.6_run/02_ifelse_comprehension.pyc
Normal file
Binary file not shown.
@@ -1,12 +1,18 @@
|
||||
# Python 2.7 sqlalchemy-1.013/sql/crud.py
|
||||
def _extend_values_for_multiparams(compiler, stmt, c):
|
||||
c(
|
||||
[
|
||||
(
|
||||
(compiler() if compiler()
|
||||
else compiler())
|
||||
if c in stmt else compiler(),
|
||||
)
|
||||
]
|
||||
for i in enumerate(stmt)
|
||||
# Adapted from Python 2.7 sqlalchemy-1.013/sql/crud.py
|
||||
# Bug was in handling generator comprehension
|
||||
# In 2.6, 2.7 JUMP_ABSOLUTEs rather than JUMP_BACKs are generated
|
||||
|
||||
# RUNNABLE!
|
||||
def extend(stmt, a, c, c1, c2, c3):
|
||||
return c(
|
||||
([ (5 if c1 else c2)
|
||||
if a else c3
|
||||
] for i in enumerate(stmt))
|
||||
)
|
||||
|
||||
def foo(gen):
|
||||
return list(gen)
|
||||
|
||||
assert extend([0], 0, foo, True, 'c2', 'c3') == [['c3']]
|
||||
assert extend([0, 1], 1, foo, False, 'c2', 'c3') == [['c2'], ['c2']]
|
||||
assert extend([0, 1], False, foo, False, 'c2', 'c3') == [['c3'], ['c3']]
|
||||
|
@@ -267,6 +267,8 @@ class Python26Parser(Python2Parser):
|
||||
# Note: preserve positions 0 2 and 4 for semantic actions
|
||||
conditional_not ::= expr jmp_true expr jf_cf_pop expr COME_FROM
|
||||
conditional ::= expr jmp_false expr jf_cf_pop expr come_from_opt
|
||||
conditional ::= expr jmp_false expr ja_cf_pop expr
|
||||
|
||||
expr ::= conditional_not
|
||||
|
||||
and ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP
|
||||
|
@@ -123,6 +123,7 @@ class Python27Parser(Python2Parser):
|
||||
conditional_true ::= expr JUMP_FORWARD expr COME_FROM
|
||||
|
||||
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
|
||||
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
|
||||
"""
|
||||
|
||||
def p_stmt27(self, args):
|
||||
|
Reference in New Issue
Block a user