mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 21:20:06 +00:00
Fold in some decompile changes
This commit is contained in:
parent
c806ef59c6
commit
3662f3e8c6
@ -13,7 +13,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
Generators and comprehenison functions
|
||||
Generators and comprehension functions
|
||||
"""
|
||||
|
||||
|
||||
@ -185,7 +185,13 @@ class ComprehensionMixin:
|
||||
self.preorder(tree[iter_index])
|
||||
self.prec = p
|
||||
|
||||
def comprehension_walk_newer(self, node, iter_index: int, code_index: int = -5):
|
||||
def comprehension_walk_newer(
|
||||
self,
|
||||
node,
|
||||
iter_index: Optional[int],
|
||||
code_index: int = -5,
|
||||
collection_node=None,
|
||||
):
|
||||
"""Non-closure-based comprehensions the way they are done in Python3
|
||||
and some Python 2.7. Note: there are also other set comprehensions.
|
||||
"""
|
||||
|
@ -1541,7 +1541,7 @@ class SourceWalker(GenericASTTraversal, ComprehensionMixin):
|
||||
|
||||
def n_list(self, node):
|
||||
"""
|
||||
prettyprint a list or tuple
|
||||
prettyprint a dict, list, set or tuple.
|
||||
"""
|
||||
p = self.prec
|
||||
self.prec = PRECEDENCE["yield"] - 1
|
||||
@ -1564,6 +1564,12 @@ class SourceWalker(GenericASTTraversal, ComprehensionMixin):
|
||||
if lastnodetype.startswith("BUILD_LIST"):
|
||||
self.write("[")
|
||||
endchar = "]"
|
||||
elif lastnodetype.startswith("BUILD_MAP_UNPACK"):
|
||||
self.write("{*")
|
||||
endchar = "}"
|
||||
elif lastnodetype.startswith("BUILD_SET"):
|
||||
self.write("{")
|
||||
endchar = "}"
|
||||
elif lastnodetype.startswith("BUILD_TUPLE"):
|
||||
# Tuples can appear places that can NOT
|
||||
# have parenthesis around them, like array
|
||||
@ -1582,12 +1588,6 @@ class SourceWalker(GenericASTTraversal, ComprehensionMixin):
|
||||
endchar = ")"
|
||||
pass
|
||||
|
||||
elif lastnodetype.startswith("BUILD_SET"):
|
||||
self.write("{")
|
||||
endchar = "}"
|
||||
elif lastnodetype.startswith("BUILD_MAP_UNPACK"):
|
||||
self.write("{*")
|
||||
endchar = "}"
|
||||
elif lastnodetype.startswith("ROT_TWO"):
|
||||
self.write("(")
|
||||
endchar = ")"
|
||||
|
Loading…
Reference in New Issue
Block a user