diff --git a/pytest/test_fstring.py b/pytest/test_fstring.py index 46dc45ad..364c529b 100644 --- a/pytest/test_fstring.py +++ b/pytest/test_fstring.py @@ -134,6 +134,10 @@ if PYTHON_VERSION > 2.6: deparsed = deparse_code(PYTHON_VERSION, code, compile_mode='single') recompiled = compile(deparsed.text, '', 'single') if recompiled != code: + print(recompiled) + print('================') + print(code) + print('----------------') assert 'dis(' + deparsed.text.strip('\n') + ')' == 'dis(' + expr.strip('\n') + ')' @@ -144,7 +148,7 @@ if PYTHON_VERSION > 2.6: run_test(fstring) - @pytest.mark.skipif(PYTHON_VERSION < 3.6, reason='need Python 3.6+') + @pytest.mark.skipif(PYTHON_VERSION != 3.6, reason='need Python 3.6+') @pytest.mark.parametrize('fstring', [ "f'{abc}{abc!s}'", "f'{abc}0'", diff --git a/uncompyle6/parsers/parse36.py b/uncompyle6/parsers/parse36.py index ef0dee17..55d5b04f 100644 --- a/uncompyle6/parsers/parse36.py +++ b/uncompyle6/parsers/parse36.py @@ -189,12 +189,16 @@ class Python36Parser(Python35Parser): expr ::= fstring_expr fstring_expr ::= expr FORMAT_VALUE - # FIXME: need to look inside FORMAT_VALUE to see if 4 - fstring_single ::= expr expr FORMAT_VALUE str ::= LOAD_CONST formatted_value ::= fstring_expr formatted_value ::= str + """ + self.add_unique_doc_rules(rules_str, customize) + elif opname == 'FORMAT_VALUE_ATTR': + rules_str = """ + expr ::= fstring_single + fstring_single ::= expr expr FORMAT_VALUE_ATTR """ self.add_unique_doc_rules(rules_str, customize) elif opname == 'MAKE_FUNCTION_8': diff --git a/uncompyle6/scanners/scanner36.py b/uncompyle6/scanners/scanner36.py index b781c871..743954f1 100644 --- a/uncompyle6/scanners/scanner36.py +++ b/uncompyle6/scanners/scanner36.py @@ -34,7 +34,11 @@ class Scanner36(Scanner3): t.kind = 'CALL_FUNCTION_EX_KW' pass elif t.op == self.opc.CALL_FUNCTION_KW: - t.kind = 'CALL_FUNCTION_KW_{t.attr}'.format(**locals()) + t.kind = 'CALL_FUNCTION_KW_%s' % t.attr + elif t.op == self.opc.FORMAT_VALUE: + if (t.attr & 0x4): + t.kind = 'FORMAT_VALUE_ATTR' + pass elif ( not_pypy36 and t.op == self.opc.BUILD_MAP_UNPACK_WITH_CALL ): t.kind = 'BUILD_MAP_UNPACK_WITH_CALL_%d' % t.attr