Skip to content

Commit cb2b90a

Browse files
committed
Python 2.5 try/except reduce fix
Start getting aligner up to date
1 parent efbd657 commit cb2b90a

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

uncompyle6/parsers/reducecheck/tryexcept.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2020, 2022, 2024 Rocky Bernstein
22

33

4-
def tryexcept(self, lhs, n: int, rule, ast, tokens, first: int, last: int):
4+
def tryexcept(self, lhs, n, rule, ast, tokens, first, last):
55
come_from_except = ast[-1]
66
if rule == (
77
"try_except",

uncompyle6/scanner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"""
2323

2424
from abc import ABC
25+
>>>>>>> Stashed changes
2526
from array import array
2627
from collections import namedtuple
2728
from types import ModuleType

uncompyle6/scanners/scanner3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def ingest(
425425
names=co.co_names,
426426
constants=co.co_consts,
427427
cells=bytecode._cell_names,
428-
linestarts=bytecode._linestarts,
428+
line_starts=bytecode._linestarts,
429429
asm_format="extended",
430430
)
431431

uncompyle6/semantics/aligner.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2022-2023 by Rocky Bernstein
1+
# Copyright (c) 2018, 2022-2024 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
@@ -18,11 +18,14 @@
1818
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
1919
from xdis import iscode
2020

21-
from xdis.version_info import IS_PYPY
21+
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
22+
2223
from uncompyle6.scanner import get_scanner
24+
from uncompyle6.semantics.consts import ASSIGN_DOC_STRING
25+
2326
from uncompyle6.semantics.pysource import (
24-
ASSIGN_DOC_STRING,
2527
RETURN_NONE,
28+
TREE_DEFAULT_DEBUG,
2629
SourceWalker,
2730
SourceWalkerError,
2831
find_globals_and_nonlocals
@@ -38,7 +41,7 @@ def __init__(
3841
version,
3942
out,
4043
scanner,
41-
showast=False,
44+
showast=TREE_DEFAULT_DEBUG,
4245
debug_parser=PARSER_DEFAULT_DEBUG,
4346
compile_mode="exec",
4447
is_pypy=False,
@@ -48,6 +51,7 @@ def __init__(
4851
)
4952
self.desired_line_number = 0
5053
self.current_line_number = 0
54+
self.showast = showast
5155

5256
def println(self, *data):
5357
if data and not (len(data) == 1 and data[0] == ""):
@@ -113,12 +117,12 @@ def default(self, node):
113117
key = key[i]
114118
pass
115119

116-
if key.type in table:
117-
self.template_engine(table[key.type], node)
120+
if key.kind in table:
121+
self.template_engine(table[key.kind], node)
118122
self.prune()
119123

120124

121-
DEFAULT_DEBUG_OPTS = {"asm": False, "tree": False, "grammar": False}
125+
DEFAULT_DEBUG_OPTS = {"asm": False, "tree": TREE_DEFAULT_DEBUG, "grammar": False}
122126

123127

124128
def code_deparse_align(
@@ -137,7 +141,7 @@ def code_deparse_align(
137141
assert iscode(co)
138142

139143
if version is None:
140-
version = float(sys.version[0:3])
144+
version = PYTHON_VERSION_TRIPLE
141145
if is_pypy is None:
142146
is_pypy = IS_PYPY
143147

@@ -156,11 +160,11 @@ def code_deparse_align(
156160
debug_parser["errorstack"] = True
157161

158162
# Build a parse tree from tokenized and massaged disassembly.
159-
show_ast = debug_opts.get("ast", None)
163+
show_ast = debug_opts.get("ast", TREE_DEFAULT_DEBUG)
160164
deparsed = AligningWalker(
161165
version,
162-
scanner,
163166
out,
167+
scanner,
164168
showast=show_ast,
165169
debug_parser=debug_parser,
166170
compile_mode=compile_mode,
@@ -210,4 +214,4 @@ def deparse_test(co):
210214
print(deparsed.text)
211215
return
212216

213-
deparse_test(deparse_test.__code__)
217+
deparse_test(deparse_test.func_code)

uncompyle6/semantics/linemap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ def deparse_test(co):
108108
# assert linemap == linemap2
109109
return
110110

111-
deparse_test(deparse_test.__code__)
111+
deparse_test(deparse_test.func_code)

0 commit comments

Comments
 (0)