You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Merge branch 'master' into python-3.3-to-3.5
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
owd=$(pwd)
|
||||||
cd $(dirname ${BASH_SOURCE[0]})
|
cd $(dirname ${BASH_SOURCE[0]})
|
||||||
if . ./setup-python-3.3.sh; then
|
if . ./setup-python-3.3.sh; then
|
||||||
git merge master
|
git merge master
|
||||||
fi
|
fi
|
||||||
|
cd $owd
|
||||||
|
@@ -18,6 +18,7 @@ SKIP_TESTS=(
|
|||||||
|
|
||||||
[test_cd.py]=1 # i# No module cl
|
[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_cmath.py]=pytest
|
||||||
[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
|
||||||
|
@@ -1,6 +1,13 @@
|
|||||||
SKIP_TESTS=(
|
SKIP_TESTS=(
|
||||||
[test_descr.py]=1 # FIXME: Works on c90ff51?
|
[test_descr.py]=1 # FIXME: Works on c90ff51?
|
||||||
|
|
||||||
|
[test_cmath.py]=1 # FIXME
|
||||||
|
# AssertionError: rect1000: rect(complex(0.0, 0.0))
|
||||||
|
# Expected: complex(0.0, 0.0)
|
||||||
|
# Received: complex(0.0, -1.0)
|
||||||
|
# Received value insufficiently close to expected value.
|
||||||
|
|
||||||
|
|
||||||
[test_cmd_line.py]=1
|
[test_cmd_line.py]=1
|
||||||
[test_collections.py]=1
|
[test_collections.py]=1
|
||||||
[test_concurrent_futures.py]=1 # too long to run over 46 seconds by itself
|
[test_concurrent_futures.py]=1 # too long to run over 46 seconds by itself
|
||||||
|
@@ -11,7 +11,7 @@ SKIP_TESTS=(
|
|||||||
[test_itertools.py]=1
|
[test_itertools.py]=1
|
||||||
|
|
||||||
[test_buffer.py]=1 # FIXME: Works on c90ff51
|
[test_buffer.py]=1 # FIXME: Works on c90ff51
|
||||||
[test_cmath.py]=1 # FIXME: Works on c90ff51
|
[test_cmath.py]=pytest
|
||||||
|
|
||||||
[test_atexit.py]=1 # The atexit test starting at 3.3 looks for specific comments in error lines
|
[test_atexit.py]=1 # The atexit test starting at 3.3 looks for specific comments in error lines
|
||||||
|
|
||||||
|
@@ -265,7 +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,
|
optype="pseudo",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for j in range(collection_start, i):
|
for j in range(collection_start, i):
|
||||||
@@ -292,7 +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,
|
optype="pseudo",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return new_tokens
|
return new_tokens
|
||||||
@@ -341,7 +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,
|
optype="pseudo",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for j in range(collection_start, i, 2):
|
for j in range(collection_start, i, 2):
|
||||||
|
@@ -89,7 +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,
|
optype="pseudo",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for j in range(collection_start, i):
|
for j in range(collection_start, i):
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2021 by Rocky Bernstein
|
# Copyright (c) 2015-2021 2024 by Rocky Bernstein
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@@ -17,20 +17,20 @@
|
|||||||
All the crazy things we have to do to handle Python functions in Python before 3.0.
|
All the crazy things we have to do to handle Python functions in Python before 3.0.
|
||||||
The saga of changes continues in 3.0 and above and in other files.
|
The saga of changes continues in 3.0 and above and in other files.
|
||||||
"""
|
"""
|
||||||
from uncompyle6.scanner import Code
|
|
||||||
from uncompyle6.semantics.parser_error import ParserError
|
|
||||||
from uncompyle6.parser import ParserError as ParserError2
|
|
||||||
from uncompyle6.semantics.helper import (
|
|
||||||
print_docstring,
|
|
||||||
find_all_globals,
|
|
||||||
find_globals_and_nonlocals,
|
|
||||||
find_none,
|
|
||||||
)
|
|
||||||
from xdis import iscode, code_has_star_arg, code_has_star_star_arg
|
|
||||||
|
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
|
|
||||||
from uncompyle6.show import maybe_show_tree_param_default
|
from xdis import code_has_star_arg, code_has_star_star_arg, iscode
|
||||||
|
|
||||||
|
from uncompyle6.scanner import Code
|
||||||
|
from uncompyle6.semantics.helper import (
|
||||||
|
find_all_globals,
|
||||||
|
find_globals_and_nonlocals,
|
||||||
|
find_none,
|
||||||
|
print_docstring,
|
||||||
|
)
|
||||||
|
from uncompyle6.semantics.parser_error import ParserError
|
||||||
|
|
||||||
|
|
||||||
def make_function2(self, node, is_lambda, nested=1, code_node=None):
|
def make_function2(self, node, is_lambda, nested=1, code_node=None):
|
||||||
"""
|
"""
|
||||||
@@ -40,8 +40,8 @@ def make_function2(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
|
|
||||||
def build_param(ast, name, default):
|
def build_param(ast, name, default):
|
||||||
"""build parameters:
|
"""build parameters:
|
||||||
- handle defaults
|
- handle defaults
|
||||||
- handle format tuple parameters
|
- handle format tuple parameters
|
||||||
"""
|
"""
|
||||||
# if formal parameter is a tuple, the paramater name
|
# if formal parameter is a tuple, the paramater name
|
||||||
# starts with a dot (eg. '.1', '.2')
|
# starts with a dot (eg. '.1', '.2')
|
||||||
@@ -52,7 +52,6 @@ def make_function2(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
|
|
||||||
if default:
|
if default:
|
||||||
value = self.traverse(default, indent="")
|
value = self.traverse(default, indent="")
|
||||||
maybe_show_tree_param_default(self.showast, name, value)
|
|
||||||
result = "%s=%s" % (name, value)
|
result = "%s=%s" % (name, value)
|
||||||
if result[-2:] == "= ": # default was 'LOAD_CONST None'
|
if result[-2:] == "= ": # default was 'LOAD_CONST None'
|
||||||
result += "None"
|
result += "None"
|
||||||
@@ -199,5 +198,5 @@ def make_function2(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
ast, code.co_name, code._customize, is_lambda=is_lambda, returnNone=rn
|
ast, code.co_name, code._customize, is_lambda=is_lambda, returnNone=rn
|
||||||
)
|
)
|
||||||
|
|
||||||
code._tokens = None # save memory
|
code._tokens = None # save memory
|
||||||
code._customize = None # save memory
|
code._customize = None # save memory
|
||||||
|
@@ -337,7 +337,6 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
- handle format tuple parameters
|
- handle format tuple parameters
|
||||||
"""
|
"""
|
||||||
value = self.traverse(default, indent="")
|
value = self.traverse(default, indent="")
|
||||||
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:
|
||||||
|
@@ -278,7 +278,7 @@ class NonterminalActions:
|
|||||||
elif elem.optype == "const" and not isinstance(elem.attr, str):
|
elif elem.optype == "const" and not isinstance(elem.attr, str):
|
||||||
value = elem.attr
|
value = elem.attr
|
||||||
else:
|
else:
|
||||||
value = "%s" % repr(elem.pattr)
|
value = "%s" % repr(elem.attr)
|
||||||
else:
|
else:
|
||||||
assert elem.kind == "ADD_VALUE_VAR"
|
assert elem.kind == "ADD_VALUE_VAR"
|
||||||
value = "%s" % elem.pattr
|
value = "%s" % elem.pattr
|
||||||
|
@@ -1271,7 +1271,7 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
|
|||||||
|
|
||||||
transform_tree = self.treeTransform.transform(ast, code)
|
transform_tree = self.treeTransform.transform(ast, code)
|
||||||
|
|
||||||
self.maybe_show_tree(ast, phase="before")
|
self.maybe_show_tree(transform_tree, phase="after")
|
||||||
|
|
||||||
del ast # Save memory
|
del ast # Save memory
|
||||||
return transform_tree
|
return transform_tree
|
||||||
|
@@ -488,19 +488,9 @@ class TreeTransform(GenericASTTraversal, object):
|
|||||||
self.ast[i] = self.ast[i][0]
|
self.ast[i] = self.ast[i][0]
|
||||||
|
|
||||||
if is_docstring(self.ast[i], self.version, code.co_consts):
|
if is_docstring(self.ast[i], self.version, code.co_consts):
|
||||||
load_const = self.ast[i].first_child()
|
load_const = copy(self.ast[i].first_child())
|
||||||
docstring_ast = SyntaxTree(
|
store_name = copy(self.ast[i].last_child())
|
||||||
"docstring",
|
docstring_ast = SyntaxTree("docstring", [load_const, store_name])
|
||||||
[
|
|
||||||
Token(
|
|
||||||
"LOAD_STR",
|
|
||||||
has_arg=True,
|
|
||||||
offset=0,
|
|
||||||
attr=load_const.attr,
|
|
||||||
pattr=load_const.pattr,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
docstring_ast.transformed_by = "transform"
|
docstring_ast.transformed_by = "transform"
|
||||||
del self.ast[i]
|
del self.ast[i]
|
||||||
self.ast.insert(0, docstring_ast)
|
self.ast.insert(0, docstring_ast)
|
||||||
|
Reference in New Issue
Block a user