From f6a13302fbdb3af4a841905b386be95ab2eb1530 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 4 Apr 2020 10:26:46 -0400 Subject: [PATCH] Bugs introduced in last commit --- pytest/test_token.py | 9 ++++----- pytest/testdata/ifelse-2.7.right | 21 +++++++++------------ uncompyle6/scanners/scanner3.py | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/pytest/test_token.py b/pytest/test_token.py index e858aa92..755d15df 100644 --- a/pytest/test_token.py +++ b/pytest/test_token.py @@ -1,14 +1,13 @@ -from uncompyle6 import PYTHON_VERSION from uncompyle6.scanners.tok import Token def test_token(): # Test token formatting of: LOAD_CONST None t = Token("LOAD_CONST", offset=0, attr=None, pattr=None, has_arg=True) - expect = " 0 LOAD_CONST None" + expect = "0 LOAD_CONST None" # print(t.format()) assert t - assert t.format() == expect + assert t.format().strip() == expect.strip() # Make sure equality testing of tokens ignores offset t2 = Token("LOAD_CONST", offset=2, attr=None, pattr=None, has_arg=True) @@ -17,8 +16,8 @@ def test_token(): # Make sure formatting of: LOAD_CONST False. We assume False is the 0th index # of co_consts. t = Token("LOAD_CONST", offset=1, attr=False, pattr=False, has_arg=True) - expect = " 1 LOAD_CONST False" - assert t.format() == expect + expect = "1 LOAD_CONST False" + assert t.format().strip() == expect.strip() if __name__ == "__main__": diff --git a/pytest/testdata/ifelse-2.7.right b/pytest/testdata/ifelse-2.7.right index f7a7d261..5746ad15 100644 --- a/pytest/testdata/ifelse-2.7.right +++ b/pytest/testdata/ifelse-2.7.right @@ -1,15 +1,12 @@ # Python 2.7 -# Embedded file name: simple_source/branching/05_ifelse.py +# Embedded file name: simple_source/branching/05_if.py - L. 3 0 LOAD_NAME 0 'True' - 3 POP_JUMP_IF_FALSE 15 'to 15' + 6 0 LOAD_NAME 0 'True' + 3 POP_JUMP_IF_FALSE 15 'to 15' - L. 4 6 LOAD_CONST 1 - 9 STORE_NAME 1 'b' - 12 JUMP_FORWARD 6 'to 21' - - L. 6 15 LOAD_CONST 2 - 18 STORE_NAME 2 'd' - 21_0 COME_FROM 12 '12' - 21 LOAD_CONST None - 24 RETURN_VALUE + 7 6 LOAD_NAME 1 'False' + 9 STORE_NAME 2 'b' + 12 JUMP_FORWARD 0 'to 15' + 15_0 COME_FROM 12 '12' + 15 LOAD_CONST None + 18 RETURN_VALUE diff --git a/uncompyle6/scanners/scanner3.py b/uncompyle6/scanners/scanner3.py index 921f8e05..a13aa56e 100644 --- a/uncompyle6/scanners/scanner3.py +++ b/uncompyle6/scanners/scanner3.py @@ -539,7 +539,7 @@ class Scanner3(Scanner): if show_asm in ("both", "after"): for t in tokens: - print(t.format(line_prefix=)) + print(t.format(line_prefix="")) print() return tokens, customize