You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Merge branch 'python-3.0-to-3.2' into python-2.4
This commit is contained in:
@@ -6,4 +6,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
|
|||||||
echo "This script should be *sourced* rather than run directly through bash"
|
echo "This script should be *sourced* rather than run directly through bash"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export PYVERSIONS='3.1.5 3.2.6'
|
export PYVERSIONS='3.0.1 3.1.5 3.2.6'
|
35
admin-tools/setup-python-3.0.sh
Normal file
35
admin-tools/setup-python-3.0.sh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PYTHON_VERSION=3.0.1
|
||||||
|
pyenv local $PYTHON_VERSION
|
||||||
|
|
||||||
|
# FIXME put some of the below in a common routine
|
||||||
|
function checkout_version {
|
||||||
|
local repo=$1
|
||||||
|
version=${2:-python-3.0-to-3.2}
|
||||||
|
echo Checking out $version on $repo ...
|
||||||
|
(cd ../$repo && git checkout $version && pyenv local $PYTHON_VERSION) && \
|
||||||
|
git pull
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function finish {
|
||||||
|
cd $owd
|
||||||
|
}
|
||||||
|
|
||||||
|
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
|
||||||
|
owd=$(pwd)
|
||||||
|
bs=${BASH_SOURCE[0]}
|
||||||
|
if [[ $0 == $bs ]] ; then
|
||||||
|
echo "This script should be *sourced* rather than run directly through bash"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mydir=$(dirname $bs)
|
||||||
|
fulldir=$(readlink -f $mydir)
|
||||||
|
cd $fulldir/..
|
||||||
|
(cd $fulldir/.. && checkout_version python-spark master && checkout_version python-xdis &&
|
||||||
|
checkout_version python-uncompyle6)
|
||||||
|
cd $owd
|
||||||
|
rm -v */.python-version || true
|
||||||
|
|
||||||
|
git checkout python-3.0-to-3.2 && git pull && pyenv local $PYTHON_VERSION
|
5
setup.py
5
setup.py
@@ -15,6 +15,11 @@ if not ((2, 4) <= SYS_VERSION <= (2, 7)):
|
|||||||
"\nFor your Python, version %s, use the python-3.3-3.5 code/branch."
|
"\nFor your Python, version %s, use the python-3.3-3.5 code/branch."
|
||||||
% sys.version[0:3]
|
% sys.version[0:3]
|
||||||
)
|
)
|
||||||
|
elif (3, 0) >= SYS_VERSION < (3, 3):
|
||||||
|
mess += (
|
||||||
|
"\nFor your Python, version %s, use the python-3.0-to-3.2 code/branch."
|
||||||
|
% sys.version[0:3]
|
||||||
|
)
|
||||||
elif SYS_VERSION < (2, 4):
|
elif SYS_VERSION < (2, 4):
|
||||||
mess += (
|
mess += (
|
||||||
"\nThis package is not supported for Python before Python 2.4 version %s." % sys.version[0:3]
|
"\nThis package is not supported for Python before Python 2.4 version %s." % sys.version[0:3]
|
||||||
|
@@ -84,6 +84,11 @@ class Python30Parser(Python31Parser):
|
|||||||
LOAD_FAST FOR_ITER store comp_iter
|
LOAD_FAST FOR_ITER store comp_iter
|
||||||
JUMP_BACK _come_froms POP_TOP JUMP_BACK
|
JUMP_BACK _come_froms POP_TOP JUMP_BACK
|
||||||
|
|
||||||
|
list_for ::= DUP_TOP STORE_FAST
|
||||||
|
expr_or_arg
|
||||||
|
FOR_ITER
|
||||||
|
store list_iter jb_or_c
|
||||||
|
|
||||||
set_comp ::= set_comp_header
|
set_comp ::= set_comp_header
|
||||||
LOAD_FAST FOR_ITER store comp_iter
|
LOAD_FAST FOR_ITER store comp_iter
|
||||||
JUMP_BACK
|
JUMP_BACK
|
||||||
@@ -218,7 +223,7 @@ class Python30Parser(Python31Parser):
|
|||||||
# lc_body ::= LOAD_NAME expr LIST_APPEND
|
# lc_body ::= LOAD_NAME expr LIST_APPEND
|
||||||
# lc_body ::= expr LIST_APPEND
|
# lc_body ::= expr LIST_APPEND
|
||||||
# list_comp ::= BUILD_LIST_0 list_iter
|
# list_comp ::= BUILD_LIST_0 list_iter
|
||||||
# list_for ::= expr FOR_ITER store list_iter jb_or_c
|
list_for ::= expr FOR_ITER store list_iter jb_or_c
|
||||||
# list_if ::= expr jmp_false list_iter
|
# list_if ::= expr jmp_false list_iter
|
||||||
# list_if ::= expr jmp_false_then list_iter
|
# list_if ::= expr jmp_false_then list_iter
|
||||||
# list_if_not ::= expr jmp_true list_iter
|
# list_if_not ::= expr jmp_true list_iter
|
||||||
|
@@ -398,7 +398,7 @@ class ComprehensionMixin(object):
|
|||||||
|
|
||||||
while n in ("list_iter", "list_afor", "list_afor2", "comp_iter"):
|
while n in ("list_iter", "list_afor", "list_afor2", "comp_iter"):
|
||||||
# iterate one nesting deeper
|
# iterate one nesting deeper
|
||||||
if self.version == 3.0 and len(n) == 3:
|
if self.version == (3, 0) and len(n) == 3:
|
||||||
assert n[0] == "expr" and n[1] == "expr"
|
assert n[0] == "expr" and n[1] == "expr"
|
||||||
n = n[1]
|
n = n[1]
|
||||||
elif n == "list_afor":
|
elif n == "list_afor":
|
||||||
@@ -411,11 +411,20 @@ class ComprehensionMixin(object):
|
|||||||
n = n[0]
|
n = n[0]
|
||||||
|
|
||||||
if n in ("list_for", "comp_for"):
|
if n in ("list_for", "comp_for"):
|
||||||
if n[2] == "store" and not store:
|
n_index = 3
|
||||||
store = n[2]
|
if (
|
||||||
|
(n[2] == "store")
|
||||||
|
or (self.version == (3, 0) and n[4] == "store")
|
||||||
|
and not store
|
||||||
|
):
|
||||||
|
if self.version == (3, 0):
|
||||||
|
store = n[4]
|
||||||
|
n_index = 5
|
||||||
|
else:
|
||||||
|
store = n[2]
|
||||||
if not comp_store:
|
if not comp_store:
|
||||||
comp_store = store
|
comp_store = store
|
||||||
n = n[3]
|
n = n[n_index]
|
||||||
elif n in (
|
elif n in (
|
||||||
"list_if",
|
"list_if",
|
||||||
"list_if_not",
|
"list_if_not",
|
||||||
@@ -462,7 +471,11 @@ class ComprehensionMixin(object):
|
|||||||
self.write(": ")
|
self.write(": ")
|
||||||
self.preorder(n[1])
|
self.preorder(n[1])
|
||||||
else:
|
else:
|
||||||
self.preorder(n[0])
|
if self.version == (3, 0):
|
||||||
|
body = n[1]
|
||||||
|
else:
|
||||||
|
body = n[0]
|
||||||
|
self.preorder(body)
|
||||||
|
|
||||||
if node == "list_comp_async":
|
if node == "list_comp_async":
|
||||||
self.write(" async")
|
self.write(" async")
|
||||||
@@ -474,6 +487,7 @@ class ComprehensionMixin(object):
|
|||||||
|
|
||||||
if comp_store:
|
if comp_store:
|
||||||
self.preorder(comp_store)
|
self.preorder(comp_store)
|
||||||
|
comp_store = None
|
||||||
else:
|
else:
|
||||||
self.preorder(store)
|
self.preorder(store)
|
||||||
|
|
||||||
@@ -546,9 +560,7 @@ class ComprehensionMixin(object):
|
|||||||
if tree[0] in ("dom_start", "dom_start_opt"):
|
if tree[0] in ("dom_start", "dom_start_opt"):
|
||||||
tree = tree[1]
|
tree = tree[1]
|
||||||
|
|
||||||
while len(tree) == 1 or (
|
while len(tree) == 1 or (tree in ("stmt", "sstmt", "return", "return_expr")):
|
||||||
tree in ("stmt", "sstmt", "return", "return_expr")
|
|
||||||
):
|
|
||||||
self.prec = 100
|
self.prec = 100
|
||||||
if tree[0] in ("dom_start", "dom_start_opt"):
|
if tree[0] in ("dom_start", "dom_start_opt"):
|
||||||
tree = tree[1]
|
tree = tree[1]
|
||||||
|
Reference in New Issue
Block a user