Skip to content

Commit a97fd62

Browse files
committed
Remove float version tests
1 parent df5da55 commit a97fd62

File tree

11 files changed

+45
-46
lines changed

11 files changed

+45
-46
lines changed

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
]
4848
}
4949
ftp_url = None
50-
install_requires = ["spark-parser >= 1.8.9, < 1.9.0", "xdis >= 6.0.2,<6.1.0"]
50+
install_requires = ["spark-parser >= 1.8.9, < 1.9.0", "xdis >= 6.0.3,<6.1.0"]
5151

5252
license = "GPL3"
5353
mailing_list = "[email protected]"

decompyle3/parsers/dump.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 Rocky Bernstein
1+
# Copyright (c) 2020-2021 Rocky Bernstein
22
#
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -14,21 +14,22 @@
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
"""Common grammar dump and check routine"""
1616

17-
def dump_and_check(p, version: float, modified_tokens: set) -> None:
17+
18+
def dump_and_check(p, version: tuple, modified_tokens: set) -> None:
1819

1920
p.dump_grammar()
2021
print("=" * 50, "\n")
2122

2223
p.check_grammar()
23-
from decompyle3 import PYTHON_VERSION, IS_PYPY
24+
from xdis.version_info import PYTHON_VERSION_TRIPLE, IS_PYPY
2425

25-
if PYTHON_VERSION == version:
26+
if PYTHON_VERSION_TRIPLE[:2] == version[:2]:
2627
lhs, rhs, tokens, right_recursive, dup_rhs = p.check_sets()
2728
from decompyle3.scanner import get_scanner
2829

29-
s = get_scanner(PYTHON_VERSION, IS_PYPY)
30+
s = get_scanner(PYTHON_VERSION_TRIPLE, IS_PYPY)
3031
modified_tokens = set(
31-
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
32+
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
3233
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
3334
LAMBDA_MARKER RETURN_LAST
3435
""".split()

decompyle3/parsers/p38/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 Rocky Bernstein
1+
# Copyright (c) 2020-2021 Rocky Bernstein
22
#
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -16,11 +16,8 @@
1616
from decompyle3.parsers.main import PythonParserSingle
1717
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
1818
from decompyle3.parsers.p38.full import Python38FullParser
19-
from decompyle3.parsers.reducecheck import (
20-
break_check,
21-
for38_check,
22-
pop_return_check
23-
)
19+
from decompyle3.parsers.reducecheck import break_check, for38_check, pop_return_check
20+
2421

2522
class Python38Parser(Python38FullParser):
2623
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG, compile_mode="exec"):
@@ -127,20 +124,22 @@ def reduce_is_invalid(self, rule, ast, tokens, first, last):
127124

128125
return False
129126

127+
130128
class Python38ParserSingle(Python38Parser, PythonParserSingle):
131129
pass
132130

133131

134132
if __name__ == "__main__":
135133
# Check grammar
136134
from decompyle3.parsers.dump import dump_and_check
135+
137136
p = Python38Parser()
138137
modified_tokens = set(
139138
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
140139
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
141140
LAMBDA_MARKER RETURN_LAST
142141
""".split()
143-
)
142+
)
144143

145144
p.remove_rules_38()
146-
dump_and_check(p, 3.8, modified_tokens)
145+
dump_and_check(p, (3, 8), modified_tokens)

decompyle3/parsers/p38/full.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,4 @@ class Python38ParserEval(Python38LambdaParser, PythonParserEval):
303303
""".split()
304304
)
305305

306-
dump_and_check(p, 3.8, modified_tokens)
306+
dump_and_check(p, (3, 8), modified_tokens)

decompyle3/parsers/p38/lambda_expr.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 Rocky Bernstein
1+
# Copyright (c) 2020-2021 Rocky Bernstein
22
#
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
2020
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
2121
from decompyle3.parsers.p37 import Python37LambdaParser
2222

23+
2324
class Python38LambdaParser(Python37LambdaParser):
2425
def p_38walrus(self, args):
2526
"""
@@ -29,18 +30,22 @@ def p_38walrus(self, args):
2930
"""
3031

3132
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG, compile_mode="lambda"):
32-
super(Python38LambdaParser, self).__init__(debug_parser, compile_mode=compile_mode)
33+
super(Python38LambdaParser, self).__init__(
34+
debug_parser, compile_mode=compile_mode
35+
)
3336
self.customized = {}
3437

38+
3539
if __name__ == "__main__":
3640
# Check grammar
3741
from decompyle3.parsers.dump import dump_and_check
42+
3843
p = Python38LambdaParser()
3944
modified_tokens = set(
4045
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
4146
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
4247
LAMBDA_MARKER RETURN_LAST
4348
""".split()
44-
)
49+
)
4550

46-
dump_and_check(p, 3.8, modified_tokens)
51+
dump_and_check(p, (3, 8), modified_tokens)

decompyle3/scanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,10 @@ def get_scanner(version, is_pypy=False, show_asm=None):
546546

547547

548548
if __name__ == "__main__":
549-
import inspect, decompyle3
549+
import inspect
550550

551551
co = inspect.currentframe().f_code
552552
from xdis.version_info import PYTHON_VERSION_TRIPLE
553553

554-
scanner = get_scanner(decompyle3.PYTHON_VERSION_TRIPLE, IS_PYPY, True)
554+
scanner = get_scanner(PYTHON_VERSION_TRIPLE, IS_PYPY, True)
555555
tokens, customize = scanner.ingest(co, {}, show_asm="after")

decompyle3/scanners/scanner37.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def ingest(self, co, classname=None, code_objects={}, show_asm=None) -> tuple:
6666

6767

6868
if __name__ == "__main__":
69-
from decompyle3 import PYTHON_VERSION
69+
from xdis.version_info import PYTHON_VERSION_TRIPLE, version_tuple_to_str
7070

71-
if PYTHON_VERSION == 3.7:
71+
if PYTHON_VERSION_TRIPLE[:2] == (3, 7):
7272
import inspect
7373

7474
co = inspect.currentframe().f_code # type: ignore
@@ -77,4 +77,4 @@ def ingest(self, co, classname=None, code_objects={}, show_asm=None) -> tuple:
7777
print(t.format())
7878
pass
7979
else:
80-
print(f"Need to be Python 3.7 to demo; I am version {PYTHON_VERSION}.")
80+
print(f"Need to be Python 3.7 to demo; I am version {version_tuple_to_str}.")

decompyle3/scanners/scanner37base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,9 @@ def next_except_jump(self, start):
924924

925925

926926
if __name__ == "__main__":
927-
from decompyle3 import PYTHON_VERSION
927+
from xdis.version_info import PYTHON_VERSION_TRIPLE, version_tuple_to_str
928928

929-
if PYTHON_VERSION >= 3.7:
929+
if PYTHON_VERSION_TRIPLE[:2] == (3, 7):
930930
import inspect
931931

932932
co = inspect.currentframe().f_code # type: ignore
@@ -936,7 +936,5 @@ def next_except_jump(self, start):
936936
for t in tokens:
937937
print(t)
938938
else:
939-
print(
940-
f"Need to be Python 3.7 or greater to demo; I am version {PYTHON_VERSION}."
941-
)
939+
print(f"Need to be Python 3.7 to demo; I am version {version_tuple_to_str}.")
942940
pass

decompyle3/scanners/scanner38.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ def ingest(
137137

138138

139139
if __name__ == "__main__":
140-
from decompyle3 import PYTHON_VERSION
140+
from xdis.version_info import PYTHON_VERSION_TRIPLE, version_tuple_to_str
141141

142-
if PYTHON_VERSION == 3.8:
142+
if PYTHON_VERSION_TRIPLE[:2] == (3, 8):
143143
import inspect
144144

145145
co = inspect.currentframe().f_code # type: ignore
@@ -148,4 +148,4 @@ def ingest(
148148
print(t.format())
149149
pass
150150
else:
151-
print(f"Need to be Python 3.8 to demo; I am {PYTHON_VERSION}.")
151+
print(f"Need to be Python 3.8 to demo; I am version {version_tuple_to_str}.")

test/simple_source/expression/14_mixed_expressions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# This code is RUNNABLE!
44

55
import sys
6-
PYTHON_VERSION = sys.version_info[0] + (sys.version_info[1] / 10.0)
76

8-
assert PYTHON_VERSION >= 3.7
7+
PYTHON_VERSION_TRIPLE = sys.version_info[:3]
8+
9+
assert PYTHON_VERSION_TRIPLE >= (3, 7)
910

1011
# some floats (from 01_float.py)
1112

@@ -20,7 +21,7 @@
2021
y = 5j
2122
assert y ** 2 == -25
2223
y **= 3
23-
assert y == (-0-125j)
24+
assert y == (-0 - 125j)
2425

2526

2627
# Tests BINARY_TRUE_DIVIDE and INPLACE_TRUE_DIVIDE (from 02_try_divide.py)

0 commit comments

Comments
 (0)