You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2
This commit is contained in:
@@ -90,7 +90,7 @@ for vers in TEST_VERSIONS:
|
|||||||
|
|
||||||
if PYTHON_VERSION_TRIPLE > (3, 0):
|
if PYTHON_VERSION_TRIPLE > (3, 0):
|
||||||
version = version_tuple_to_str(end=2)
|
version = version_tuple_to_str(end=2)
|
||||||
PYC = f"*.cpython-{version}.pyc"
|
PYC = "*.cpython-%s.pyc" % version
|
||||||
test_options[vers] = (sys.path[-1], PYC, short_vers)
|
test_options[vers] = (sys.path[-1], PYC, short_vers)
|
||||||
else:
|
else:
|
||||||
short_vers = vers[:3]
|
short_vers = vers[:3]
|
||||||
|
@@ -314,17 +314,25 @@ class Scanner3(Scanner):
|
|||||||
if count < 5:
|
if count < 5:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
collection_start = i - (count * 2)
|
if self.version >= (3, 5):
|
||||||
assert (count * 2) <= i
|
# Newer Python BUILD_MAP argument's count is a
|
||||||
|
# key and value pair so it is multiplied by two.
|
||||||
|
collection_start = i - (count * 2)
|
||||||
|
assert (count * 2) <= i
|
||||||
|
|
||||||
for j in range(collection_start, i, 2):
|
for j in range(collection_start, i, 2):
|
||||||
if insts[j].opname not in ("LOAD_CONST",):
|
if insts[j].opname not in ("LOAD_CONST",):
|
||||||
return None
|
return None
|
||||||
if insts[j + 1].opname not in ("LOAD_CONST",):
|
if insts[j + 1].opname not in ("LOAD_CONST",):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
collection_start = i - (2 * count)
|
collection_start = i - (2 * count)
|
||||||
collection_enum = CONST_COLLECTIONS.index("CONST_MAP")
|
collection_enum = CONST_COLLECTIONS.index("CONST_MAP")
|
||||||
|
# else: Older Python count is sum of all key and value pairs
|
||||||
|
# Each pair is added individually like:
|
||||||
|
# LOAD_CONST ("Max-Age")
|
||||||
|
# LOAD_CONST ("max-age")
|
||||||
|
# STORE_MAP
|
||||||
|
|
||||||
# If we get here, all instructions before tokens[i] are LOAD_CONST and
|
# If we get here, all instructions before tokens[i] are LOAD_CONST and
|
||||||
# we can replace add a boundary marker and change LOAD_CONST to
|
# we can replace add a boundary marker and change LOAD_CONST to
|
||||||
@@ -521,7 +529,7 @@ class Scanner3(Scanner):
|
|||||||
if try_tokens is not None:
|
if try_tokens is not None:
|
||||||
new_tokens = try_tokens
|
new_tokens = try_tokens
|
||||||
continue
|
continue
|
||||||
elif opname in ("BUILD_MAP",):
|
elif opname in ("BUILD_MAP",) and self.version >= (3, 5):
|
||||||
try_tokens = self.bound_map_from_inst(
|
try_tokens = self.bound_map_from_inst(
|
||||||
self.insts,
|
self.insts,
|
||||||
new_tokens,
|
new_tokens,
|
||||||
|
@@ -20,6 +20,7 @@ import re
|
|||||||
from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE, TABLE_DIRECT
|
from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE, TABLE_DIRECT
|
||||||
from uncompyle6.semantics.helper import flatten_list
|
from uncompyle6.semantics.helper import flatten_list
|
||||||
|
|
||||||
|
# FIXME get from a newer xdis
|
||||||
FSTRING_CONVERSION_MAP = {1: "!s", 2: "!r", 3: "!a", "X": ":X"}
|
FSTRING_CONVERSION_MAP = {1: "!s", 2: "!r", 3: "!a", "X": ":X"}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user