You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Misc cleanups...
remove code now in xdis require at least xdis 3.5.4 PyPy tolerance in validate testing
This commit is contained in:
@@ -40,7 +40,7 @@ entry_points = {
|
|||||||
]}
|
]}
|
||||||
ftp_url = None
|
ftp_url = None
|
||||||
install_requires = ['spark-parser >= 1.6.1, < 1.7.0',
|
install_requires = ['spark-parser >= 1.6.1, < 1.7.0',
|
||||||
'xdis == 3.5.1', 'six']
|
'xdis >= 3.5.4, < 3.6.0', 'six']
|
||||||
license = 'MIT'
|
license = 'MIT'
|
||||||
mailing_list = 'python-debugger@googlegroups.com'
|
mailing_list = 'python-debugger@googlegroups.com'
|
||||||
modname = 'uncompyle6'
|
modname = 'uncompyle6'
|
||||||
|
@@ -123,7 +123,9 @@ def validate_uncompyle(text, mode='exec'):
|
|||||||
original_text = text
|
original_text = text
|
||||||
|
|
||||||
deparsed = deparse_code(PYTHON_VERSION, original_code,
|
deparsed = deparse_code(PYTHON_VERSION, original_code,
|
||||||
compile_mode=mode, out=six.StringIO())
|
compile_mode=mode,
|
||||||
|
out=six.StringIO(),
|
||||||
|
is_pypy=IS_PYPY)
|
||||||
uncompyled_text = deparsed.text
|
uncompyled_text = deparsed.text
|
||||||
uncompyled_code = compile(uncompyled_text, '<string>', 'exec')
|
uncompyled_code = compile(uncompyled_text, '<string>', 'exec')
|
||||||
|
|
||||||
|
@@ -11,13 +11,10 @@ from __future__ import print_function
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from xdis.code import iscode
|
from xdis.code import iscode
|
||||||
|
from xdis.magics import py_str2float
|
||||||
from spark_parser import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
from spark_parser import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
from uncompyle6.show import maybe_show_asm
|
from uncompyle6.show import maybe_show_asm
|
||||||
|
|
||||||
# FIXME: put in xdis
|
|
||||||
from uncompyle6.scanner import version_str2float
|
|
||||||
|
|
||||||
|
|
||||||
class ParserError(Exception):
|
class ParserError(Exception):
|
||||||
def __init__(self, token, offset):
|
def __init__(self, token, offset):
|
||||||
self.token = token
|
self.token = token
|
||||||
@@ -610,7 +607,7 @@ def get_python_parser(
|
|||||||
|
|
||||||
# If version is a string, turn that into the corresponding float.
|
# If version is a string, turn that into the corresponding float.
|
||||||
if isinstance(version, str):
|
if isinstance(version, str):
|
||||||
version = version_str2float(version)
|
version = py_str2float(version)
|
||||||
|
|
||||||
# FIXME: there has to be a better way...
|
# FIXME: there has to be a better way...
|
||||||
# We could do this as a table lookup, but that would force us
|
# We could do this as a table lookup, but that would force us
|
||||||
|
@@ -17,6 +17,7 @@ import sys
|
|||||||
from uncompyle6 import PYTHON3, IS_PYPY
|
from uncompyle6 import PYTHON3, IS_PYPY
|
||||||
from uncompyle6.scanners.tok import Token
|
from uncompyle6.scanners.tok import Token
|
||||||
from xdis.bytecode import op_size
|
from xdis.bytecode import op_size
|
||||||
|
from xdis.magics import py_str2float
|
||||||
|
|
||||||
# The byte code versions we support
|
# The byte code versions we support
|
||||||
PYTHON_VERSIONS = (1.5,
|
PYTHON_VERSIONS = (1.5,
|
||||||
@@ -258,28 +259,11 @@ def parse_fn_counts(argc):
|
|||||||
return ((argc & 0xFF), (argc >> 8) & 0xFF, (argc >> 16) & 0x7FFF)
|
return ((argc & 0xFF), (argc >> 8) & 0xFF, (argc >> 16) & 0x7FFF)
|
||||||
|
|
||||||
|
|
||||||
# FIXME: put in xdis
|
|
||||||
from xdis.magics import magics
|
|
||||||
def version_str2float(version):
|
|
||||||
if version in magics:
|
|
||||||
magic = magics[version]
|
|
||||||
for v, m in list(magics.items()):
|
|
||||||
if m == magic:
|
|
||||||
try:
|
|
||||||
return float(v)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
pass
|
|
||||||
pass
|
|
||||||
raise RuntimeError("Can't find a valid Python version for version %s"
|
|
||||||
% version)
|
|
||||||
return
|
|
||||||
|
|
||||||
def get_scanner(version, is_pypy=False, show_asm=None):
|
def get_scanner(version, is_pypy=False, show_asm=None):
|
||||||
|
|
||||||
# If version is a string, turn that into the corresponding float.
|
# If version is a string, turn that into the corresponding float.
|
||||||
if isinstance(version, str):
|
if isinstance(version, str):
|
||||||
version = version_str2float(version)
|
version = py_str2float(version)
|
||||||
|
|
||||||
# Pick up appropriate scanner
|
# Pick up appropriate scanner
|
||||||
if version in PYTHON_VERSIONS:
|
if version in PYTHON_VERSIONS:
|
||||||
|
Reference in New Issue
Block a user