Skip to content

Commit c01ab5e

Browse files
committed
Tweaks to long-literal handling...
* Use version tuple comparison for version testing * small lintin of n_actions * revise test so assert is not removed in 3.8
1 parent 6f3fe06 commit c01ab5e

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed
150 Bytes
Binary file not shown.

test/simple_source/expression/05_long_literals.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,12 @@
726726

727727
assert sorted(values.values())[1:] == list(range(2, 34))
728728

729+
def assert_equal(x, y):
730+
assert x == y
729731

730732
# Check that we can distinguish names from strings in literal collections, e.g. lists.
731733
# The list has to have more than 4 items to get accumulated in a collection
732734
a = ["y", 'Exception', "x", Exception, "z"]
733-
assert a[1] == "Exception"
734-
assert a[3] == Exception
735+
736+
assert_equal(a[1], "Exception")
737+
assert_equal(a[3], Exception)

uncompyle6/semantics/n_actions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 by Rocky Bernstein
1+
# Copyright (c) 2022-2023 by 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
@@ -159,7 +159,7 @@ def n_classdef(self, node):
159159
# * class_name - the name of the class
160160
# * subclass_info - the parameters to the class e.g.
161161
# class Foo(bar, baz)
162-
# -----------
162+
# ------------
163163
# * subclass_code - the code for the subclass body
164164

165165
if node == "classdefdeco2":
@@ -181,7 +181,7 @@ def n_classdef(self, node):
181181
subclass_code = build_class[-3][1].attr
182182
class_name = node[0][0].pattr
183183
else:
184-
raise "Internal Error n_classdef: cannot find class name"
184+
raise RuntimeError("Internal Error n_classdef: cannot find class name")
185185

186186
if node == "classdefdeco2":
187187
self.write("\n")
@@ -228,7 +228,8 @@ def n_const_list(self, node):
228228
else:
229229
# from trepan.api import debug; debug()
230230
raise TypeError(
231-
f"Internal Error: n_const_list expects dict, list set, or set; got {lastnodetype}"
231+
("Internal Error: n_const_list expects dict, list set, or set; got "
232+
f"{lastnodetype}")
232233
)
233234

234235
self.indent_more(INDENT_PER_LEVEL)
@@ -267,7 +268,7 @@ def n_const_list(self, node):
267268
if elem == "add_value":
268269
elem = elem[0]
269270
if elem == "ADD_VALUE":
270-
if self.version[0] == 2:
271+
if self.version < (3, 0, 0):
271272
value = "%r" % elem.pattr
272273
else:
273274
value = "%s" % elem.pattr

0 commit comments

Comments
 (0)