diff --git a/test/bytecode_3.1/03_if_true_else.pyc b/test/bytecode_3.1/03_if_true_else.pyc new file mode 100644 index 00000000..5085777c Binary files /dev/null and b/test/bytecode_3.1/03_if_true_else.pyc differ diff --git a/test/simple_source/bug27+/03_if_true_else.py b/test/simple_source/bug27+/03_if_true_else.py new file mode 100644 index 00000000..bfdcae3c --- /dev/null +++ b/test/simple_source/bug27+/03_if_true_else.py @@ -0,0 +1 @@ +1 if 1 else __file__ diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 5169d550..9ab80c95 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -508,8 +508,12 @@ class PythonParser(GenericASTBuilder): expr ::= conditional conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr + expr ::= conditionalnot - conditionalnot ::= expr jmp_true expr _jump expr COME_FROM + conditionalnot ::= expr jmp_true expr _jump expr COME_FROM + + expr ::= conditionalTrue + conditionalTrue ::= expr JUMP_FORWARD expr COME_FROM ret_expr ::= expr ret_expr ::= ret_and diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index b011f064..1c530bc2 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -409,7 +409,6 @@ class Python3Parser(PythonParser): conditional ::= expr jmp_false expr jf_else expr COME_FROM conditionalnot ::= expr jmp_true expr jf_else expr COME_FROM - expr ::= LOAD_CLASSNAME # Python 3.4+ diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index ee233ae3..6570522b 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -170,6 +170,7 @@ TABLE_DIRECT = { 'or': ( '%c or %c', 0, 2 ), 'ret_or': ( '%c or %c', 0, 2 ), 'conditional': ( '%p if %p else %p', (2, 27), (0, 27), (4, 27)), + 'conditionalTrue': ( '%p if 1 else %p', (0, 27), (2, 27)), 'ret_cond': ( '%p if %p else %p', (2, 27), (0, 27), (-1, 27)), 'conditionalnot': ( '%p if not %p else %p', (2, 27), (0, 22), (4, 27)), 'ret_cond_not': ( '%p if not %p else %p', (2, 27), (0, 22), (-1, 27)),