mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-10-07 10:13:39 +00:00
Better fstring handling for FORMAT_VALUE | 0x4
This commit is contained in:
parent
f54cf20d9d
commit
fac365f216
@ -134,6 +134,10 @@ if PYTHON_VERSION > 2.6:
|
||||
deparsed = deparse_code(PYTHON_VERSION, code, compile_mode='single')
|
||||
recompiled = compile(deparsed.text, '<string>', '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'",
|
||||
|
@ -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':
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user