Skip to content

Commit 4e8c62c

Browse files
committed
Merge branch 'master' into python-3.6-to-3.10
2 parents c303c8a + 329d331 commit 4e8c62c

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

uncompyle6/show.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2018, 2020, 2023 Rocky Bernstein <rocky@gnu.org>
1+
# Copyright (C) 2018, 2020, 2023, 2026 Rocky Bernstein <rocky@gnu.org>
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
@@ -13,9 +13,10 @@
1313
# You should have received a copy of the GNU General Public License
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
import sys
16+
from typing import Any
1617

1718

18-
def maybe_show_asm(showasm, tokens):
19+
def maybe_show_asm(showasm: Any, tokens: list) -> None:
1920
"""
2021
Show the asm based on the showasm flag (or file object), writing to the
2122
appropriate stream depending on the type of the flag.
@@ -32,15 +33,15 @@ def maybe_show_asm(showasm, tokens):
3233
stream.write("\n")
3334

3435

35-
def maybe_show_tree(walker, ast):
36+
def maybe_show_tree(walker, tree) -> None:
3637
"""
37-
Show the ast based on the showast flag (or file object), writing to the
38+
Show the tree based on the tree flag (or file object), writing to the
3839
appropriate stream depending on the type of the flag.
3940
4041
:param show_tree: Flag which determines whether the parse tree is
4142
written to sys.stdout or not. (It is also to pass a file
4243
like object, into which the ast will be written).
43-
:param ast: The ast to show.
44+
:param tree: The tree to show.
4445
"""
4546
if walker.showast:
4647
if hasattr(walker.showast, "write"):
@@ -51,14 +52,15 @@ def maybe_show_tree(walker, ast):
5152
isinstance(walker.showast, dict)
5253
and walker.showast.get("after", False)
5354
and hasattr(walker, "str_with_template")
55+
and walker.str_with_template
5456
):
55-
walker.str_with_template(ast)
57+
walker.str_with_template(tree)
5658
else:
57-
stream.write(str(ast))
59+
stream.write(str(tree))
5860
stream.write("\n")
5961

6062

61-
def maybe_show_tree_param_default(show_tree, name, default):
63+
def maybe_show_tree_param_default(show_tree, name: str, default):
6264
"""
6365
Show a function parameter with default for an grammar-tree based on the show_tree flag
6466
(or file object), writing to the appropriate stream depending on the type

uncompyle6/util.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
# More could be done here though.
44

55
from math import copysign
6+
67
from xdis.cross_types import UnicodeForPython3
7-
from xdis.version_info import PYTHON_VERSION_TRIPLE
8+
89

910
def get_code_name(code) -> str:
1011
code_name = code.co_name
1112
if isinstance(code_name, UnicodeForPython3):
1213
return code_name.value.decode("utf-8")
1314
return code_name
1415

16+
1517
def is_negative_zero(n):
1618
"""Returns true if n is -0.0"""
1719
return n == 0.0 and copysign(1, n) == -1
@@ -42,12 +44,6 @@ def better_repr(v, version):
4244
if len(v) == 1:
4345
return "(%s,)" % better_repr(v[0], version)
4446
return "(%s)" % ", ".join(better_repr(i, version) for i in v)
45-
elif PYTHON_VERSION_TRIPLE < (3, 0) and isinstance(v, long):
46-
s = repr(v)
47-
if version >= 3.0 and s[-1] == "L":
48-
return s[:-1]
49-
else:
50-
return s
5147
elif isinstance(v, list):
5248
if len(v) == 1:
5349
return "[%s,]" % better_repr(v[0], version)

0 commit comments

Comments
 (0)