Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2

This commit is contained in:
rocky
2024-02-24 17:45:42 -05:00
12 changed files with 72 additions and 44 deletions

View File

@@ -8,23 +8,22 @@ SKIP_TESTS=(
# [test_shutil.py]=1 # OK but needs PYTHON=pytest # [test_shutil.py]=1 # OK but needs PYTHON=pytest
[test___all__.py]=1 # it fails on its own [test___all__.py]=1 # it fails on its own
[test_aepack.py]=1 # it fails on its own [test_aepack.py]=1 # No module macostools
[test_al.py]=1 # it fails on its own [test_al.py]=1 # No module macostools
[test_anydbm.py]=1 # it fails on its own [test_anydbm.py]=pytest
[test_applesingle.py]=1 # it fails on its own [test_applesingle.py]=1 # No module macostools
[test_bsddb185.py]=1 # it fails on its own [test_bsddb185.py]=1 # it fails on its own
[test_bsddb3.py]=1 # it fails on its own [test_bsddb3.py]=1 # it fails on its own
[test_bsddb.py]=1 # it fails on its own [test_bsddb.py]=1 # No module _bsdb
# [test_cd.py]=1 # it fails on its own [test_cd.py]=1 # i# No module cl
[test_cl.py]=1 # it fails on its own [test_cl.py]=1 # it fails on its own
[test_codecmaps_cn.py]=1 # it fails on its own [test_codecmaps_cn.py]=1 # it fails on its own
[test_codecmaps_jp.py]=1 # it fails on its own [test_codecmaps_jp.py]=1 # it fails on its own
[test_codecmaps_kr.py]=1 # it fails on its own [test_codecmaps_kr.py]=1 # it fails on its own
[test_codecmaps_tw.py]=1 # it fails on its own [test_codecmaps_tw.py]=1 # it fails on its own
[test_commands.py]=1 # it fails on its own [test_commands.py]=1 # it fails on its own
[test_curses.py]=1 # it fails on its own [test_curses.py]=1 # needs libncurses.so.5
[test_dbm.py]=1 # it fails on its own [test_dbm.py]=1 # it fails on its own
[test_descr.py]=1 [test_descr.py]=1
@@ -33,16 +32,16 @@ SKIP_TESTS=(
[test_dl.py]=1 # it fails on its own [test_dl.py]=1 # it fails on its own
[test_file.py]=1 # it fails on its own [test_file.py]=1 # it fails on its own
[test_future5.py]=1 # it fails on its own [test_future5.py]=pytest
# [test_generators.py]=1 # works but use PYTHON=pytest [test_generators.py]=pytest
[test_gl.py]=1 # it fails on its own [test_gl.py]=1 # it fails on its own
# [test_grp.py]=1 # works but use PYTHON=pytest [test_grp.py]=pytest
[test_imageop.py]=1 # it fails on its own [test_imageop.py]=1 # it fails on its own
[test_imaplib.py]=1 # it fails on its own [test_imaplib.py]=1 # it fails on its own
[test_imgfile.py]=1 # it fails on its own [test_imgfile.py]=1 # it fails on its own
# [test_ioctl.py]=1 # works but use PYTHON=pytest [test_ioctl.py]=pytest
[test_kqueue.py]=1 # it fails on its own [test_kqueue.py]=1 # it fails on its own
@@ -63,6 +62,7 @@ SKIP_TESTS=(
[test_scriptpackages.py]=1 # it fails on its own [test_scriptpackages.py]=1 # it fails on its own
[test_select.py]=1 # test takes too long to run: 11 seconds [test_select.py]=1 # test takes too long to run: 11 seconds
[test_signal.py]=1 # takes more than 15 seconds to run
[test_socket.py]=1 # test takes too long to run: 12 seconds [test_socket.py]=1 # test takes too long to run: 12 seconds
[test_startfile.py]=1 # it fails on its own [test_startfile.py]=1 # it fails on its own
[test_structmembers.py]=1 # it fails on its own [test_structmembers.py]=1 # it fails on its own
@@ -81,8 +81,8 @@ SKIP_TESTS=(
[test_winreg.py]=1 # it fails on its own [test_winreg.py]=1 # it fails on its own
[test_winsound.py]=1 # it fails on its own [test_winsound.py]=1 # it fails on its own
[test_zipimport_support.py]=1 # expected test to raise ImportError [test_zipimport_support.py]=pytest # expected test to raise ImportError
[test_zipfile64.py]=1 # Skip Long test [test_zipfile.py]=pytest # Skip Long test
# .pyenv/versions/2.6.9/lib/python2.6/lib2to3/refactor.pyc # .pyenv/versions/2.6.9/lib/python2.6/lib2to3/refactor.pyc
# .pyenv/versions/2.6.9/lib/python2.6/pyclbr.pyc # .pyenv/versions/2.6.9/lib/python2.6/pyclbr.pyc
) )

View File

@@ -1,6 +1,6 @@
SKIP_TESTS=( SKIP_TESTS=(
[test_ast.py]=1 # FIXME: Works on c90ff51 [test_ast.py]=1 # FIXME: Works on c90ff51
[test_cmath.py]=1 # FIXME: Works on c90ff51 [test_cmath.py]=1 # fails on its own
[test_format.py]=1 # FIXME: Works on c90ff51 [test_format.py]=1 # FIXME: Works on c90ff51
[test_ftplib.py]=1 # FIXME: Works on c90ff51 [test_ftplib.py]=1 # FIXME: Works on c90ff51
[test_slice.py]=1 # FIXME: Works on c90ff51 [test_slice.py]=1 # FIXME: Works on c90ff51

View File

@@ -36,7 +36,7 @@ SKIP_TESTS=(
[test_bdb.py]=1 # [test_bdb.py]=1 #
[test_buffer.py]=1 # parse error [test_buffer.py]=1 # parse error
[test_clinic.py]=1 # it fails on its own [test_clinic.py]=1 # it fails on its own
[test_cmath.py]=1 # test assertion failure [test_cmath.py]=pytest
[test_cmd_line.py]=1 # Interactive? [test_cmd_line.py]=1 # Interactive?
[test_cmd_line_script.py]=1 [test_cmd_line_script.py]=1
[test_compileall.py]=1 # fails on its own [test_compileall.py]=1 # fails on its own

View File

@@ -69,7 +69,7 @@ SKIP_TESTS=(
[test_cgi.py]=1 # parse error [test_cgi.py]=1 # parse error
[test_cgitb.py]=1 # parse error [test_cgitb.py]=1 # parse error
[test_clinic.py]=1 # it fails on its own [test_clinic.py]=1 # it fails on its own
[test_cmath.py]=1 # test assertion failure [test_cmath.py]=pytest
[test_cmd.py]=1 # parse error [test_cmd.py]=1 # parse error
[test_cmd_line.py]=1 # Interactive? [test_cmd_line.py]=1 # Interactive?
[test_cmd_line_script.py]=1 [test_cmd_line_script.py]=1

View File

@@ -187,7 +187,11 @@ if [[ -n $1 ]] ; then
files=$@ files=$@
typeset -a files_ary=( $(echo $@) ) typeset -a files_ary=( $(echo $@) )
if (( ${#files_ary[@]} == 1 || DONT_SKIP_TESTS == 1 )) ; then if (( ${#files_ary[@]} == 1 || DONT_SKIP_TESTS == 1 )) ; then
SKIP_TESTS=() for file in $files; do
if (( SKIP_TESTS[$file] != "pytest" )); then
SKIP_TESTS[$file]=1;
fi
done
fi fi
else else
files=$(echo test_*.py) files=$(echo test_*.py)
@@ -201,9 +205,14 @@ NOT_INVERTED_TESTS=${NOT_INVERTED_TESTS:-1}
for file in $files; do for file in $files; do
# AIX bash doesn't grok [[ -v SKIP... ]] # AIX bash doesn't grok [[ -v SKIP... ]]
[[ -z ${SKIP_TESTS[$file]} ]] && SKIP_TESTS[$file]=0 [[ -z ${SKIP_TESTS[$file]} ]] && SKIP_TESTS[$file]=0
if [[ ${SKIP_TESTS[$file]} == ${NOT_INVERTED_TESTS} ]] ; then
((skipped++)) if [[ ${SKIP_TESTS[$file]} == "pytest" ]]; then
continue PYTHON=pytest
else
if [[ ${SKIP_TESTS[$file]}s == ${NOT_INVERTED_TESTS} ]] ; then
((skipped++))
continue
fi
fi fi
# If the fails *before* decompiling, skip it! # If the fails *before* decompiling, skip it!

View File

@@ -265,6 +265,7 @@ class Scanner3(Scanner):
has_arg=True, has_arg=True,
has_extended_arg=False, has_extended_arg=False,
opc=self.opc, opc=self.opc,
optype=None,
) )
) )
for j in range(collection_start, i): for j in range(collection_start, i):
@@ -278,6 +279,7 @@ class Scanner3(Scanner):
has_arg=True, has_arg=True,
has_extended_arg=False, has_extended_arg=False,
opc=self.opc, opc=self.opc,
optype=insts[j].optype,
) )
) )
new_tokens.append( new_tokens.append(
@@ -290,6 +292,7 @@ class Scanner3(Scanner):
has_arg=t.has_arg, has_arg=t.has_arg,
has_extended_arg=False, has_extended_arg=False,
opc=t.opc, opc=t.opc,
optype=None,
) )
) )
return new_tokens return new_tokens
@@ -338,6 +341,7 @@ class Scanner3(Scanner):
has_arg=True, has_arg=True,
has_extended_arg=False, has_extended_arg=False,
opc=self.opc, opc=self.opc,
optype=None,
) )
) )
for j in range(collection_start, i, 2): for j in range(collection_start, i, 2):
@@ -363,6 +367,7 @@ class Scanner3(Scanner):
has_arg=True, has_arg=True,
has_extended_arg=False, has_extended_arg=False,
opc=self.opc, opc=self.opc,
optype=insts[j + 1].optype,
) )
) )
new_tokens.append( new_tokens.append(
@@ -375,6 +380,7 @@ class Scanner3(Scanner):
has_arg=t.has_arg, has_arg=t.has_arg,
has_extended_arg=False, has_extended_arg=False,
opc=t.opc, opc=t.opc,
optype=t.optype,
) )
) )
return new_tokens return new_tokens

View File

@@ -89,6 +89,7 @@ class Scanner37(Scanner37Base):
has_arg=True, has_arg=True,
has_extended_arg=False, has_extended_arg=False,
opc=self.opc, opc=self.opc,
optype=None,
) )
) )
for j in range(collection_start, i): for j in range(collection_start, i):
@@ -102,6 +103,7 @@ class Scanner37(Scanner37Base):
has_arg=True, has_arg=True,
has_extended_arg=False, has_extended_arg=False,
opc=self.opc, opc=self.opc,
optype=tokens[j].optype,
) )
) )
new_tokens.append( new_tokens.append(

View File

@@ -352,6 +352,7 @@ class Scanner37Base(Scanner):
has_arg=True, has_arg=True,
opc=self.opc, opc=self.opc,
has_extended_arg=False, has_extended_arg=False,
optype=inst.optype,
), ),
) )
jump_idx += 1 jump_idx += 1
@@ -423,6 +424,7 @@ class Scanner37Base(Scanner):
has_arg=inst.has_arg, has_arg=inst.has_arg,
opc=self.opc, opc=self.opc,
has_extended_arg=inst.has_extended_arg, has_extended_arg=inst.has_extended_arg,
optype=inst.optype,
), ),
) )
continue continue
@@ -524,6 +526,7 @@ class Scanner37Base(Scanner):
has_arg=inst.has_arg, has_arg=inst.has_arg,
opc=self.opc, opc=self.opc,
has_extended_arg=inst.has_extended_arg, has_extended_arg=inst.has_extended_arg,
optype=inst.optype,
), ),
) )
pass pass

View File

@@ -66,11 +66,13 @@ class Token:
has_arg=None, has_arg=None,
opc=None, opc=None,
has_extended_arg=False, has_extended_arg=False,
optype=None,
): ):
self.kind = intern(opname) self.kind = intern(opname)
self.has_arg = has_arg self.has_arg = has_arg
self.attr = attr self.attr = attr
self.pattr = pattr self.pattr = pattr
self.optype = optype
if has_extended_arg: if has_extended_arg:
self.offset = "%d_%d" % (offset, offset + 2) self.offset = "%d_%d" % (offset, offset + 2)
else: else:
@@ -106,8 +108,8 @@ class Token:
self.op = op self.op = op
def __eq__(self, o): def __eq__(self, o):
""" '==' on kind and "pattr" attributes. """'==' on kind and "pattr" attributes.
It is okay if offsets and linestarts are different""" It is okay if offsets and linestarts are different"""
if isinstance(o, Token): if isinstance(o, Token):
return (self.kind == o.kind) and ( return (self.kind == o.kind) and (
(self.pattr == o.pattr) or self.attr == o.attr (self.pattr == o.pattr) or self.attr == o.attr
@@ -117,7 +119,7 @@ class Token:
return self.kind == o return self.kind == o
def __ne__(self, o): def __ne__(self, o):
""" '!=', but it's okay if offsets and linestarts are different""" """'!=', but it's okay if offsets and linestarts are different"""
return not self.__eq__(o) return not self.__eq__(o)
def __repr__(self): def __repr__(self):

View File

@@ -136,7 +136,7 @@ ASSIGN_DOC_STRING = lambda doc_string, doc_load: SyntaxTree(
SyntaxTree( SyntaxTree(
"expr", [Token(doc_load, pattr=doc_string, attr=doc_string)] "expr", [Token(doc_load, pattr=doc_string, attr=doc_string)]
), ),
SyntaxTree("store", [Token("STORE_NAME", pattr="__doc__")]), SyntaxTree("store", [Token("STORE_NAME", pattr="__doc__", optype="name")]),
], ],
) )
@@ -148,10 +148,10 @@ NAME_MODULE = SyntaxTree(
"assign", "assign",
[ [
SyntaxTree( SyntaxTree(
"expr", [Token("LOAD_NAME", pattr="__name__", offset=0, has_arg=True)] "expr", [Token("LOAD_NAME", pattr="__name__", offset=0, has_arg=True, optype="name")]
), ),
SyntaxTree( SyntaxTree(
"store", [Token("STORE_NAME", pattr="__module__", offset=3, has_arg=True)] "store", [Token("STORE_NAME", pattr="__module__", offset=3, has_arg=True, optype="name")]
), ),
], ],
) )

View File

@@ -17,22 +17,21 @@ All the crazy things we have to do to handle Python functions in 3.6 and above.
The saga of changes before 3.6 is in other files. The saga of changes before 3.6 is in other files.
""" """
from xdis import ( from xdis import (
iscode, CO_ASYNC_GENERATOR,
CO_GENERATOR,
code_has_star_arg, code_has_star_arg,
code_has_star_star_arg, code_has_star_star_arg,
CO_GENERATOR, iscode,
CO_ASYNC_GENERATOR,
) )
from uncompyle6.scanner import Code
from uncompyle6.semantics.parser_error import ParserError
from uncompyle6.parser import ParserError as ParserError2 from uncompyle6.parser import ParserError as ParserError2
from uncompyle6.scanner import Code
from uncompyle6.semantics.helper import ( from uncompyle6.semantics.helper import (
find_all_globals, find_all_globals,
find_globals_and_nonlocals, find_globals_and_nonlocals,
find_none, find_none,
) )
from uncompyle6.semantics.parser_error import ParserError
from uncompyle6.show import maybe_show_tree_param_default
def make_function36(self, node, is_lambda, nested=1, code_node=None): def make_function36(self, node, is_lambda, nested=1, code_node=None):
@@ -55,7 +54,6 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None):
- handle format tuple parameters - handle format tuple parameters
""" """
value = default value = default
maybe_show_tree_param_default(self.showast, name, value)
if annotation: if annotation:
result = "%s: %s=%s" % (name, annotation, value) result = "%s: %s=%s" % (name, annotation, value)
else: else:
@@ -150,7 +148,7 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None):
kwonlyargcount = code.co_kwonlyargcount kwonlyargcount = code.co_kwonlyargcount
paramnames = list(scanner_code.co_varnames[:argc]) paramnames = list(scanner_code.co_varnames[:argc])
kwargs = list(scanner_code.co_varnames[argc: argc + kwonlyargcount]) kwargs = list(scanner_code.co_varnames[argc : argc + kwonlyargcount])
paramnames.reverse() paramnames.reverse()
defparams.reverse() defparams.reverse()
@@ -181,7 +179,7 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None):
) )
) )
for param in paramnames[i + 1:]: for param in paramnames[i + 1 :]:
if param in annotate_dict: if param in annotate_dict:
params.append("%s: %s" % (param, annotate_dict[param])) params.append("%s: %s" % (param, annotate_dict[param]))
else: else:

View File

@@ -240,10 +240,15 @@ class NonterminalActions:
assert len(keys) == len(flat_elems) - 1 assert len(keys) == len(flat_elems) - 1
for i, elem in enumerate(flat_elems[:-1]): for i, elem in enumerate(flat_elems[:-1]):
assert elem.kind == "ADD_VALUE" assert elem.kind == "ADD_VALUE"
try: if elem.optype in ("local", "name"):
value = "%r" % elem.pattr value = elem.attr
except Exception: elif elem.optype == "const" and not isinstance(elem.attr, str):
value = elem.pattr value = elem.attr
else:
try:
value = "%r" % elem.pattr
except Exception:
value = elem.pattr
if elem.linestart is not None: if elem.linestart is not None:
if elem.linestart != self.line_number: if elem.linestart != self.line_number:
next_indent = self.indent + INDENT_PER_LEVEL[:-1] next_indent = self.indent + INDENT_PER_LEVEL[:-1]
@@ -266,11 +271,14 @@ class NonterminalActions:
for elem in flat_elems: for elem in flat_elems:
if elem == "add_value": if elem == "add_value":
elem = elem[0] elem = elem[0]
if elem == "ADD_VALUE": if elem == "ADD_VALUE":
if self.version < (3, 0, 0): if elem.optype in ("local", "name"):
value = "%r" % repr(elem.pattr) value = elem.attr
elif elem.optype == "const" and not isinstance(elem.attr, str):
value = elem.attr
else: else:
value = "%s" % str(elem.pattr) value = "%s" % repr(elem.pattr)
else: else:
assert elem.kind == "ADD_VALUE_VAR" assert elem.kind == "ADD_VALUE_VAR"
value = "%s" % elem.pattr value = "%s" % elem.pattr