Python 2.5 try/except reduce fix

Start getting aligner up to date
This commit is contained in:
rocky 2024-07-12 14:15:04 -04:00
parent efbd6570b0
commit cb2b90a94f
5 changed files with 19 additions and 14 deletions

View File

@ -1,7 +1,7 @@
# Copyright (c) 2020, 2022, 2024 Rocky Bernstein
def tryexcept(self, lhs, n: int, rule, ast, tokens, first: int, last: int):
def tryexcept(self, lhs, n, rule, ast, tokens, first, last):
come_from_except = ast[-1]
if rule == (
"try_except",

View File

@ -22,6 +22,7 @@ scanners, e.g. for Python 2.7 or 3.4.
"""
from abc import ABC
>>>>>>> Stashed changes
from array import array
from collections import namedtuple
from types import ModuleType

View File

@ -425,7 +425,7 @@ class Scanner3(Scanner):
names=co.co_names,
constants=co.co_consts,
cells=bytecode._cell_names,
linestarts=bytecode._linestarts,
line_starts=bytecode._linestarts,
asm_format="extended",
)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018, 2022-2023 by Rocky Bernstein
# Copyright (c) 2018, 2022-2024 by Rocky Bernstein
#
# 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
@ -18,11 +18,14 @@ import sys
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from xdis import iscode
from xdis.version_info import IS_PYPY
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
from uncompyle6.scanner import get_scanner
from uncompyle6.semantics.consts import ASSIGN_DOC_STRING
from uncompyle6.semantics.pysource import (
ASSIGN_DOC_STRING,
RETURN_NONE,
TREE_DEFAULT_DEBUG,
SourceWalker,
SourceWalkerError,
find_globals_and_nonlocals
@ -38,7 +41,7 @@ class AligningWalker(SourceWalker, object):
version,
out,
scanner,
showast=False,
showast=TREE_DEFAULT_DEBUG,
debug_parser=PARSER_DEFAULT_DEBUG,
compile_mode="exec",
is_pypy=False,
@ -48,6 +51,7 @@ class AligningWalker(SourceWalker, object):
)
self.desired_line_number = 0
self.current_line_number = 0
self.showast = showast
def println(self, *data):
if data and not (len(data) == 1 and data[0] == ""):
@ -113,12 +117,12 @@ class AligningWalker(SourceWalker, object):
key = key[i]
pass
if key.type in table:
self.template_engine(table[key.type], node)
if key.kind in table:
self.template_engine(table[key.kind], node)
self.prune()
DEFAULT_DEBUG_OPTS = {"asm": False, "tree": False, "grammar": False}
DEFAULT_DEBUG_OPTS = {"asm": False, "tree": TREE_DEFAULT_DEBUG, "grammar": False}
def code_deparse_align(
@ -137,7 +141,7 @@ def code_deparse_align(
assert iscode(co)
if version is None:
version = float(sys.version[0:3])
version = PYTHON_VERSION_TRIPLE
if is_pypy is None:
is_pypy = IS_PYPY
@ -156,11 +160,11 @@ def code_deparse_align(
debug_parser["errorstack"] = True
# Build a parse tree from tokenized and massaged disassembly.
show_ast = debug_opts.get("ast", None)
show_ast = debug_opts.get("ast", TREE_DEFAULT_DEBUG)
deparsed = AligningWalker(
version,
scanner,
out,
scanner,
showast=show_ast,
debug_parser=debug_parser,
compile_mode=compile_mode,
@ -210,4 +214,4 @@ if __name__ == "__main__":
print(deparsed.text)
return
deparse_test(deparse_test.__code__)
deparse_test(deparse_test.func_code)

View File

@ -108,4 +108,4 @@ if __name__ == "__main__":
# assert linemap == linemap2
return
deparse_test(deparse_test.__code__)
deparse_test(deparse_test.func_code)