You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Fix fragment bugs
mostly with respect to show_ast handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2019, 2021-2022 by Rocky Bernstein
|
# Copyright (c) 2015-2019, 2021-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
|
||||||
@@ -1169,11 +1169,14 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
self.p.insts = self.scanner.insts
|
self.p.insts = self.scanner.insts
|
||||||
self.p.offset2inst_index = self.scanner.offset2inst_index
|
self.p.offset2inst_index = self.scanner.offset2inst_index
|
||||||
ast = python_parser.parse(self.p, tokens, customize, code)
|
ast = python_parser.parse(self.p, tokens, customize, code)
|
||||||
|
self.customize(customize)
|
||||||
self.p.insts = p_insts
|
self.p.insts = p_insts
|
||||||
|
|
||||||
except (python_parser.ParserError, AssertionError) as e:
|
except (python_parser.ParserError, AssertionError) as e:
|
||||||
raise ParserError(e, tokens)
|
raise ParserError(e, tokens)
|
||||||
|
transform_tree = self.treeTransform.transform(ast, code)
|
||||||
maybe_show_tree(self, ast)
|
maybe_show_tree(self, ast)
|
||||||
return ast
|
return transform_tree
|
||||||
|
|
||||||
# The bytecode for the end of the main routine has a
|
# The bytecode for the end of the main routine has a
|
||||||
# "return None". However you can't issue a "return" statement in
|
# "return None". However you can't issue a "return" statement in
|
||||||
@@ -1199,23 +1202,28 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
if len(tokens) == 0:
|
if len(tokens) == 0:
|
||||||
return PASS
|
return PASS
|
||||||
|
|
||||||
# Build parse tree from tokenized and massaged disassembly.
|
# Build a parse tree from tokenized and massaged disassembly.
|
||||||
try:
|
try:
|
||||||
# FIXME: have p.insts update in a better way
|
# FIXME: have p.insts update in a better way
|
||||||
# modularity is broken here
|
# modularity is broken here
|
||||||
p_insts = self.p.insts
|
p_insts = self.p.insts
|
||||||
self.p.insts = self.scanner.insts
|
self.p.insts = self.scanner.insts
|
||||||
self.p.offset2inst_index = self.scanner.offset2inst_index
|
self.p.offset2inst_index = self.scanner.offset2inst_index
|
||||||
|
self.p.opc = self.scanner.opc
|
||||||
ast = parser.parse(self.p, tokens, customize, code)
|
ast = parser.parse(self.p, tokens, customize, code)
|
||||||
self.p.insts = p_insts
|
self.p.insts = p_insts
|
||||||
except (parser.ParserError, AssertionError) as e:
|
except (python_parser.ParserError, AssertionError) as e:
|
||||||
raise ParserError(e, tokens, {})
|
raise ParserError(e, tokens, {})
|
||||||
|
|
||||||
maybe_show_tree(self, ast)
|
|
||||||
|
|
||||||
checker(ast, False, self.ast_errors)
|
checker(ast, False, self.ast_errors)
|
||||||
|
|
||||||
return ast
|
self.customize(customize)
|
||||||
|
transform_tree = self.treeTransform.transform(ast, code)
|
||||||
|
|
||||||
|
maybe_show_tree(self, ast)
|
||||||
|
|
||||||
|
del ast # Save memory
|
||||||
|
return transform_tree
|
||||||
|
|
||||||
# FIXME: we could provide another customized routine
|
# FIXME: we could provide another customized routine
|
||||||
# that fixes up parents along a particular path to a node that
|
# that fixes up parents along a particular path to a node that
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2018, 2020 Rocky Bernstein <rocky@gnu.org>
|
# Copyright (C) 2018, 2020, 2023 Rocky Bernstein <rocky@gnu.org>
|
||||||
#
|
#
|
||||||
# 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
|
||||||
|
Reference in New Issue
Block a user