Bugs introduced in last commit

This commit is contained in:
rocky
2020-04-04 10:26:46 -04:00
parent e8e7d2086d
commit f6a13302fb
3 changed files with 14 additions and 18 deletions

View File

@@ -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__":

View File

@@ -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'
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

View File

@@ -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