diff --git a/admin-tools/pyenv-3.1-3.2-versions b/admin-tools/pyenv-3.0-3.2-versions similarity index 86% rename from admin-tools/pyenv-3.1-3.2-versions rename to admin-tools/pyenv-3.0-3.2-versions index 334a2631..df84c5bf 100644 --- a/admin-tools/pyenv-3.1-3.2-versions +++ b/admin-tools/pyenv-3.0-3.2-versions @@ -6,4 +6,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then echo "This script should be *sourced* rather than run directly through bash" exit 1 fi -export PYVERSIONS='3.1.5 3.2.6' +export PYVERSIONS='3.0.1 3.1.5 3.2.6' diff --git a/admin-tools/setup-python-3.0.sh b/admin-tools/setup-python-3.0.sh new file mode 100644 index 00000000..27282d53 --- /dev/null +++ b/admin-tools/setup-python-3.0.sh @@ -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 diff --git a/setup.py b/setup.py index 495117b5..77ad0279 100755 --- a/setup.py +++ b/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." % 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): mess += ( "\nThis package is not supported for Python before Python 2.4 version %s." % sys.version[0:3] diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index b38e96cc..0c395118 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -84,6 +84,11 @@ class Python30Parser(Python31Parser): LOAD_FAST FOR_ITER store comp_iter 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 LOAD_FAST FOR_ITER store comp_iter JUMP_BACK @@ -218,7 +223,7 @@ class Python30Parser(Python31Parser): # lc_body ::= LOAD_NAME expr LIST_APPEND # lc_body ::= expr LIST_APPEND # 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_then list_iter # list_if_not ::= expr jmp_true list_iter diff --git a/uncompyle6/semantics/gencomp.py b/uncompyle6/semantics/gencomp.py index 3ed4ee74..ffc3306b 100644 --- a/uncompyle6/semantics/gencomp.py +++ b/uncompyle6/semantics/gencomp.py @@ -398,7 +398,7 @@ class ComprehensionMixin(object): while n in ("list_iter", "list_afor", "list_afor2", "comp_iter"): # 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" n = n[1] elif n == "list_afor": @@ -411,11 +411,20 @@ class ComprehensionMixin(object): n = n[0] if n in ("list_for", "comp_for"): - if n[2] == "store" and not store: - store = n[2] + n_index = 3 + 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: comp_store = store - n = n[3] + n = n[n_index] elif n in ( "list_if", "list_if_not", @@ -462,7 +471,11 @@ class ComprehensionMixin(object): self.write(": ") self.preorder(n[1]) 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": self.write(" async") @@ -474,6 +487,7 @@ class ComprehensionMixin(object): if comp_store: self.preorder(comp_store) + comp_store = None else: self.preorder(store) @@ -546,9 +560,7 @@ class ComprehensionMixin(object): if tree[0] in ("dom_start", "dom_start_opt"): tree = tree[1] - while len(tree) == 1 or ( - tree in ("stmt", "sstmt", "return", "return_expr") - ): + while len(tree) == 1 or (tree in ("stmt", "sstmt", "return", "return_expr")): self.prec = 100 if tree[0] in ("dom_start", "dom_start_opt"): tree = tree[1]