You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Sync 3.8 and Makefile changes with decompyle3
Makefile: pyston 2.3 tolerance fragments: 3.8 comprehension adjustments
This commit is contained in:
@@ -13,7 +13,7 @@ PHONY=check clean dist distclean test test-unit test-functional rmChangeLog clea
|
||||
GIT2CL ?= git2cl
|
||||
PYTHON ?= python
|
||||
|
||||
PYTHON_VERSION = $(shell $(PYTHON) -V 2>&1 | cut -d ' ' -f 2 | cut -d'.' -f1,2)
|
||||
PYTHON_VERSION = $(shell $(PYTHON) -V 2>&1 | cut -d ' ' -f 2 | cut -d'.' -f1,2 | head -1)
|
||||
NATIVE_CHECK = check-$(PYTHON_VERSION)
|
||||
|
||||
# Set COMPILE='--compile' to force compilation before check
|
||||
@@ -22,7 +22,7 @@ COVER_DIR=../tmp/grammar-cover
|
||||
|
||||
# Run short tests
|
||||
check-short:
|
||||
@$(PYTHON) -V && PYTHON_VERSION=`$(PYTHON) -V 2>&1 | cut -d ' ' -f 2 | cut -d'.' -f1,2`; \
|
||||
@$(PYTHON) -V && PYTHON_VERSION=`$(PYTHON) -V 2>&1 | cut -d ' ' -f 2 | cut -d'.' -f1,2` | head -1; \
|
||||
$(MAKE) check-bytecode-$${PYTHON_VERSION}
|
||||
|
||||
# Run all tests
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2019 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2019, 2021 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
|
||||
@@ -659,7 +659,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
# FIXME: clean this up
|
||||
if self.version > 3.0 and node == "dict_comp":
|
||||
cn = node[1]
|
||||
elif self.version > 3.0 and node == "generator_exp":
|
||||
elif self.version > 3.0 and node in ("generator_exp", "generator_exp_async"):
|
||||
if node[0] == "load_genexpr":
|
||||
load_genexpr = node[0]
|
||||
elif node[1] == "load_genexpr":
|
||||
@@ -687,11 +687,15 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
|
||||
n = ast[iter_index]
|
||||
assert n == "comp_iter"
|
||||
# find innermost node
|
||||
while n == "comp_iter":
|
||||
# Find the comprehension body. It is the inner-most
|
||||
# node that is not list_.. .
|
||||
while n == "comp_iter": # list_iter
|
||||
n = n[0] # recurse one step
|
||||
if n == "comp_for":
|
||||
n = n[3]
|
||||
if n[0] == "SETUP_LOOP":
|
||||
n = n[4]
|
||||
else:
|
||||
n = n[3]
|
||||
elif n == "comp_if":
|
||||
n = n[2]
|
||||
elif n == "comp_ifnot":
|
||||
@@ -699,16 +703,31 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
assert n == "comp_body", ast
|
||||
|
||||
self.preorder(n[0])
|
||||
if node == "generator_exp_async":
|
||||
self.write(" async")
|
||||
iter_var_index = iter_index - 2
|
||||
else:
|
||||
iter_var_index = iter_index - 1
|
||||
self.write(" for ")
|
||||
start = len(self.f.getvalue())
|
||||
store = ast[iter_index - 1]
|
||||
store = ast[iter_var_index]
|
||||
self.preorder(store)
|
||||
self.set_pos_info(ast[iter_index - 1], start, len(self.f.getvalue()))
|
||||
self.write(" in ")
|
||||
start = len(self.f.getvalue())
|
||||
|
||||
node[-3].parent = node
|
||||
self.preorder(node[-3])
|
||||
self.set_pos_info(node[-3], start, len(self.f.getvalue()))
|
||||
|
||||
if node[2] == "expr":
|
||||
iter_expr = node[2]
|
||||
else:
|
||||
iter_expr = node[-3]
|
||||
assert iter_expr == "expr"
|
||||
iter_expr.parent = node
|
||||
self.preorder(iter_expr)
|
||||
self.set_pos_info(iter_expr, start, len(self.f.getvalue()))
|
||||
start = len(self.f.getvalue())
|
||||
self.preorder(ast[iter_index])
|
||||
self.set_pos_info(ast[iter_index], start, len(self.f.getvalue()))
|
||||
|
Reference in New Issue
Block a user