You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
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
This commit is contained in:
Binary file not shown.
@@ -726,9 +726,12 @@ values = {
|
|||||||
|
|
||||||
assert sorted(values.values())[1:] == list(range(2, 34))
|
assert sorted(values.values())[1:] == list(range(2, 34))
|
||||||
|
|
||||||
|
def assert_equal(x, y):
|
||||||
|
assert x == y
|
||||||
|
|
||||||
# Check that we can distinguish names from strings in literal collections, e.g. lists.
|
# Check that we can distinguish names from strings in literal collections, e.g. lists.
|
||||||
# The list has to have more than 4 items to get accumulated in a collection
|
# The list has to have more than 4 items to get accumulated in a collection
|
||||||
a = ["y", 'Exception', "x", Exception, "z"]
|
a = ["y", 'Exception', "x", Exception, "z"]
|
||||||
assert a[1] == "Exception"
|
|
||||||
assert a[3] == Exception
|
assert_equal(a[1], "Exception")
|
||||||
|
assert_equal(a[3], Exception)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2022 by Rocky Bernstein
|
# Copyright (c) 2022-2023 by Rocky Bernstein
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -159,7 +159,7 @@ class NonterminalActions:
|
|||||||
# * class_name - the name of the class
|
# * class_name - the name of the class
|
||||||
# * subclass_info - the parameters to the class e.g.
|
# * subclass_info - the parameters to the class e.g.
|
||||||
# class Foo(bar, baz)
|
# class Foo(bar, baz)
|
||||||
# -----------
|
# ------------
|
||||||
# * subclass_code - the code for the subclass body
|
# * subclass_code - the code for the subclass body
|
||||||
|
|
||||||
if node == "classdefdeco2":
|
if node == "classdefdeco2":
|
||||||
@@ -181,7 +181,7 @@ class NonterminalActions:
|
|||||||
subclass_code = build_class[-3][1].attr
|
subclass_code = build_class[-3][1].attr
|
||||||
class_name = node[0][0].pattr
|
class_name = node[0][0].pattr
|
||||||
else:
|
else:
|
||||||
raise "Internal Error n_classdef: cannot find class name"
|
raise RuntimeError("Internal Error n_classdef: cannot find class name")
|
||||||
|
|
||||||
if node == "classdefdeco2":
|
if node == "classdefdeco2":
|
||||||
self.write("\n")
|
self.write("\n")
|
||||||
@@ -228,7 +228,8 @@ class NonterminalActions:
|
|||||||
else:
|
else:
|
||||||
# from trepan.api import debug; debug()
|
# from trepan.api import debug; debug()
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f"Internal Error: n_const_list expects dict, list set, or set; got {lastnodetype}"
|
("Internal Error: n_const_list expects dict, list set, or set; got "
|
||||||
|
f"{lastnodetype}")
|
||||||
)
|
)
|
||||||
|
|
||||||
self.indent_more(INDENT_PER_LEVEL)
|
self.indent_more(INDENT_PER_LEVEL)
|
||||||
@@ -267,7 +268,7 @@ class NonterminalActions:
|
|||||||
if elem == "add_value":
|
if elem == "add_value":
|
||||||
elem = elem[0]
|
elem = elem[0]
|
||||||
if elem == "ADD_VALUE":
|
if elem == "ADD_VALUE":
|
||||||
if self.version[0] == 2:
|
if self.version < (3, 0, 0):
|
||||||
value = "%r" % elem.pattr
|
value = "%r" % elem.pattr
|
||||||
else:
|
else:
|
||||||
value = "%s" % elem.pattr
|
value = "%s" % elem.pattr
|
||||||
|
Reference in New Issue
Block a user