mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-12-03 18:41:03 +00:00
Merge pull request #364 from rocky/PYTHON3-move
use xdis.PYTHON3 not uncompyle.PYTHON3
This commit is contained in:
commit
9b5d953614
@ -1,6 +1,5 @@
|
||||
import pytest
|
||||
from uncompyle6.semantics.fragments import code_deparse as deparse, deparsed_find
|
||||
from uncompyle6 import PYTHON_VERSION, PYTHON3
|
||||
from uncompyle6.semantics.fragments import code_deparse as deparse
|
||||
from xdis.version_info import PYTHON_VERSION, PYTHON3
|
||||
|
||||
def map_stmts(x, y):
|
||||
x = []
|
||||
@ -37,13 +36,11 @@ def check_expect(expect, parsed, fn_name):
|
||||
debug = False
|
||||
i = 2
|
||||
max_expect = len(expect)
|
||||
code = get_parsed_for_fn(fn_name)
|
||||
for name, offset in sorted(parsed.offsets.keys()):
|
||||
assert i+1 <= max_expect, (
|
||||
"%s: ran out if items in testing node" % fn_name)
|
||||
nodeInfo = parsed.offsets[name, offset]
|
||||
node = nodeInfo.node
|
||||
nodeInfo2 = deparsed_find((name, offset), parsed, code)
|
||||
extractInfo = parsed.extract_node_info(node)
|
||||
|
||||
assert expect[i] == extractInfo.selectedLine, \
|
||||
|
@ -1,11 +1,11 @@
|
||||
import sys
|
||||
from uncompyle6 import PYTHON3
|
||||
from uncompyle6.scanner import get_scanner
|
||||
from uncompyle6.semantics.consts import (
|
||||
escape, NONE,
|
||||
# RETURN_NONE, PASS, RETURN_LOCALS
|
||||
)
|
||||
|
||||
from xdis.version_info import PYTHON3
|
||||
if PYTHON3:
|
||||
from io import StringIO
|
||||
def iteritems(d):
|
||||
|
@ -1,9 +1,10 @@
|
||||
import pytest
|
||||
from uncompyle6 import PYTHON_VERSION, code_deparse
|
||||
pytestmark = pytest.mark.skip(PYTHON_VERSION < 2.7,
|
||||
from uncompyle6 import code_deparse
|
||||
from xdis.version_info import PYTHON_VERSION_TRIPLE
|
||||
pytestmark = pytest.mark.skip(PYTHON_VERSION_TRIPLE < (2, 7),
|
||||
reason="need at least Python 2.7")
|
||||
|
||||
if PYTHON_VERSION > 2.6:
|
||||
if PYTHON_VERSION_TRIPLE > (2, 6):
|
||||
def test_single_mode():
|
||||
single_expressions = (
|
||||
'i = 1',
|
||||
|
@ -84,8 +84,8 @@ check-3.10: check-bytecode
|
||||
@echo "Note that we do not support decompiling Python 3.10 bytecode - no 3.10 tests run"
|
||||
|
||||
# FIXME
|
||||
#: this is called when running under pypy3.5-5.8.0, pypy2-5.6.0, or pypy3.6-7.3.0
|
||||
5.8 5.6:
|
||||
#: this is called when running under pypy3.5-5.8.0, pypy2-5.6.0, pypy3.6-7.3.0 or pypy3.8-7.3.7
|
||||
5.8 5.6 7.3:
|
||||
|
||||
#: Check deparsing only, but from a different Python version
|
||||
check-disasm:
|
||||
|
@ -14,11 +14,11 @@ def a():
|
||||
def c():
|
||||
k = 34
|
||||
global i
|
||||
i += k
|
||||
i = i+k
|
||||
l = 42
|
||||
c()
|
||||
global j
|
||||
j += l
|
||||
j = j+l
|
||||
b()
|
||||
print i, j # should print 35, 49
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
def f():
|
||||
print x # would result in a 'NameError' or 'UnboundLocalError'
|
||||
x += 1
|
||||
x = x+1
|
||||
print x
|
||||
|
||||
raise "This program can't be run"
|
||||
|
@ -28,7 +28,7 @@ else:
|
||||
|
||||
i = 0
|
||||
while i < 10:
|
||||
i += 1
|
||||
i = i+1
|
||||
if i == 3:
|
||||
continue
|
||||
if i == 5:
|
||||
@ -40,7 +40,7 @@ print
|
||||
|
||||
i = 0
|
||||
while i < 10:
|
||||
i += 1
|
||||
i = i+1
|
||||
if i == 3:
|
||||
continue
|
||||
print i,
|
||||
|
@ -55,9 +55,9 @@ class DBRecIO:
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
if mode == 1:
|
||||
pos += self.pos
|
||||
pos = pos + self.pos
|
||||
elif mode == 2:
|
||||
pos += self.len
|
||||
pos = pos + self.len
|
||||
self.pos = max(0, pos)
|
||||
|
||||
def tell(self):
|
||||
@ -84,7 +84,7 @@ class DBRecIO:
|
||||
if self.closed:
|
||||
raise ValueError, "I/O operation on closed file"
|
||||
if self.buflist:
|
||||
self.buf += string.joinfields(self.buflist, '')
|
||||
self.buf = self.buf + string.joinfields(self.buflist, '')
|
||||
self.buflist = []
|
||||
i = string.find(self.buf, '\n', self.pos)
|
||||
if i < 0:
|
||||
|
@ -3,7 +3,7 @@ def flatten(tup):
|
||||
elts = []
|
||||
for elt in tup:
|
||||
if isinstance(elt, tuple):
|
||||
elts += flatten(elt)
|
||||
elts = elts + flatten(elt)
|
||||
else:
|
||||
elts.append(elt)
|
||||
return elts
|
||||
@ -53,7 +53,7 @@ def mangle(name, klass):
|
||||
try:
|
||||
i = 0
|
||||
while klass[i] == '_':
|
||||
i += 1
|
||||
i = i + 1
|
||||
except IndexError:
|
||||
return name
|
||||
klass = klass[i:]
|
||||
|
@ -30,7 +30,7 @@ class SyntaxErrorChecker:
|
||||
self.errors = 0
|
||||
|
||||
def error(self, node, msg):
|
||||
self.errors += 1
|
||||
self.errors = self.errors + 1
|
||||
if self.multi is not None:
|
||||
print "%s:%s: %s" % (node.filename, node.lineno, msg)
|
||||
else:
|
||||
|
@ -9,11 +9,11 @@ def normpath(comps):
|
||||
del comps[i]
|
||||
elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'):
|
||||
del comps[i-1:i+1]
|
||||
i -= 1
|
||||
i = i - 1
|
||||
elif comps[i] == '' and i > 0 and comps[i-1] != '':
|
||||
del comps[i]
|
||||
else:
|
||||
i += 1
|
||||
i = i + 1
|
||||
return comps
|
||||
|
||||
assert normpath(['.']) == []
|
||||
|
@ -2,7 +2,7 @@
|
||||
# messing up control flow detection
|
||||
def _format_usage(self, usage, actions, groups, prefix):
|
||||
if usage:
|
||||
usage %= dict(prog=self._prog)
|
||||
usage = usage % dict(prog=self._prog)
|
||||
|
||||
elif usage is None:
|
||||
prog = 5
|
||||
|
@ -31,9 +31,9 @@ from __future__ import print_function
|
||||
|
||||
import getopt, os, py_compile, sys, shutil, tempfile, time
|
||||
|
||||
from uncompyle6 import PYTHON_VERSION
|
||||
from uncompyle6.main import main
|
||||
from fnmatch import fnmatch
|
||||
from uncompyle6.main import main
|
||||
from xdis.version_info import PYTHON_VERSION
|
||||
|
||||
|
||||
def get_srcdir():
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
Copyright (c) 2015, 2018 by Rocky Bernstein
|
||||
Copyright (c) 2015, 2018, 2021 by Rocky Bernstein
|
||||
Copyright (c) 2000 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
Copyright (c) 1999 John Aycock
|
||||
|
||||
@ -30,18 +30,7 @@ import sys
|
||||
|
||||
__docformat__ = "restructuredtext"
|
||||
|
||||
from uncompyle6.version import __version__
|
||||
|
||||
PYTHON3 = sys.version_info >= (3, 0)
|
||||
|
||||
# We do this crazy way to support Python 2.6 which
|
||||
# doesn't support version_major, and has a bug in
|
||||
# floating point so we can't divide 26 by 10 and get
|
||||
# 2.6
|
||||
PYTHON_VERSION = sys.version_info[0] + (sys.version_info[1] / 10.0)
|
||||
PYTHON_VERSION_STR = "%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||
|
||||
IS_PYPY = "__pypy__" in sys.builtin_module_names
|
||||
from uncompyle6.version import __version__ # noqa
|
||||
|
||||
if hasattr(sys, "setrecursionlimit"):
|
||||
# pyston doesn't have setrecursionlimit
|
||||
@ -51,7 +40,7 @@ import uncompyle6.semantics.pysource
|
||||
import uncompyle6.semantics.fragments
|
||||
|
||||
# Export some functions
|
||||
from uncompyle6.main import decompile_file
|
||||
from uncompyle6.main import decompile_file # noqa
|
||||
|
||||
# Convenience functions so you can say:
|
||||
# from uncompyle6 import (code_deparse, deparse_code2str)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis.version_info import PYTHON3
|
||||
from uncompyle6.scanners.tok import NoneToken
|
||||
from spark_parser.ast import AST as spark_AST
|
||||
|
||||
|
@ -40,7 +40,7 @@ from copy import copy
|
||||
from xdis import code2num, iscode, op_has_argument, instruction_size
|
||||
from xdis.bytecode import _get_const_info
|
||||
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
from sys import intern
|
||||
|
@ -23,7 +23,7 @@ use in deparsing.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis.version_info import PYTHON3
|
||||
if PYTHON3:
|
||||
intern = sys.intern
|
||||
|
||||
|
@ -47,7 +47,7 @@ import xdis.opcodes.opcode_33 as op3
|
||||
from uncompyle6.scanner import Scanner
|
||||
|
||||
import sys
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
intern = sys.intern
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2016-2020 by Rocky Bernstein
|
||||
# Copyright (c) 2016-2021 by Rocky Bernstein
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
# Copyright (c) 1999 John Aycock
|
||||
#
|
||||
@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import re, sys
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
intern = sys.intern
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
import re, sys
|
||||
from uncompyle6.parsers.treenode import SyntaxTree
|
||||
from uncompyle6 import PYTHON3
|
||||
from uncompyle6.scanners.tok import Token, NoneToken
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
minint = -sys.maxsize - 1
|
||||
|
@ -3,7 +3,7 @@ import sys
|
||||
from xdis import iscode
|
||||
from uncompyle6.parsers.treenode import SyntaxTree
|
||||
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis.version_info import PYTHON3
|
||||
if PYTHON3:
|
||||
minint = -sys.maxsize-1
|
||||
maxint = sys.maxsize
|
||||
|
@ -17,9 +17,7 @@
|
||||
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.
|
||||
"""
|
||||
from xdis import iscode, code_has_star_arg, code_has_star_star_arg
|
||||
from uncompyle6.scanner import Code
|
||||
from uncompyle6 import PYTHON3
|
||||
from uncompyle6.semantics.parser_error import ParserError
|
||||
from uncompyle6.parser import ParserError as ParserError2
|
||||
from uncompyle6.semantics.helper import (
|
||||
@ -28,6 +26,8 @@ from uncompyle6.semantics.helper import (
|
||||
find_globals_and_nonlocals,
|
||||
find_none,
|
||||
)
|
||||
from xdis import iscode, code_has_star_arg, code_has_star_star_arg
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
from itertools import zip_longest
|
||||
|
@ -24,16 +24,14 @@ from xdis import (
|
||||
CO_ASYNC_GENERATOR,
|
||||
)
|
||||
from uncompyle6.scanner import Code
|
||||
from uncompyle6.parsers.treenode import SyntaxTree
|
||||
from uncompyle6.semantics.parser_error import ParserError
|
||||
from uncompyle6.parser import ParserError as ParserError2
|
||||
from uncompyle6 import PYTHON3
|
||||
from uncompyle6.semantics.helper import (
|
||||
print_docstring,
|
||||
find_all_globals,
|
||||
find_globals_and_nonlocals,
|
||||
find_none,
|
||||
)
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
from itertools import zip_longest
|
||||
|
@ -3,7 +3,7 @@
|
||||
# More could be done here though.
|
||||
|
||||
from math import copysign
|
||||
from uncompyle6 import PYTHON_VERSION
|
||||
from xdis.version_info import PYTHON_VERSION
|
||||
|
||||
|
||||
def is_negative_zero(n):
|
||||
|
@ -26,8 +26,8 @@ from subprocess import call
|
||||
|
||||
import uncompyle6
|
||||
from uncompyle6.scanner import Token as ScannerToken, get_scanner
|
||||
from uncompyle6 import PYTHON3
|
||||
from xdis import iscode, load_file, load_module, pretty_code_flags, PYTHON_MAGIC_INT
|
||||
from xdis.version_info import PYTHON3
|
||||
|
||||
# FIXME: DRY
|
||||
if PYTHON3:
|
||||
|
Loading…
Reference in New Issue
Block a user