You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Python 2.x compatibility
This commit is contained in:
@@ -492,7 +492,7 @@ class Scanner2(Scanner):
|
||||
if show_asm in ("both", "after"):
|
||||
print("\n# ---- tokenization:")
|
||||
# FIXME: t.format() is changing tokens!
|
||||
for t in new_tokens.copy():
|
||||
for t in copy(new_tokens):
|
||||
print(t.format(line_prefix=""))
|
||||
print()
|
||||
return new_tokens, customize
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#######################
|
||||
# Python 1.4- Changes #
|
||||
#######################
|
||||
def customize_for_version14(self, version: tuple):
|
||||
def customize_for_version14(self, version):
|
||||
self.TABLE_DIRECT.update(
|
||||
{
|
||||
"print_expr_stmt": (("%|print %c\n", 0)),
|
||||
|
@@ -15,10 +15,8 @@
|
||||
"""Isolate Python 2.6 and 2.7 version-specific semantic actions here.
|
||||
"""
|
||||
|
||||
from uncompyle6.semantics.consts import TABLE_DIRECT
|
||||
|
||||
|
||||
def customize_for_version26_27(self, version: tuple):
|
||||
def customize_for_version26_27(self, version):
|
||||
########################################
|
||||
# Python 2.6+
|
||||
# except <condition> as <var>
|
||||
|
@@ -19,7 +19,6 @@ Isolate Python 3 version-specific semantic actions here.
|
||||
|
||||
from xdis import iscode
|
||||
|
||||
from uncompyle6.semantics.consts import TABLE_DIRECT
|
||||
from uncompyle6.semantics.customize35 import customize_for_version35
|
||||
from uncompyle6.semantics.customize36 import customize_for_version36
|
||||
from uncompyle6.semantics.customize37 import customize_for_version37
|
||||
@@ -28,7 +27,7 @@ from uncompyle6.semantics.helper import find_code_node, gen_function_parens_adju
|
||||
from uncompyle6.semantics.make_function3 import make_function3_annotate
|
||||
|
||||
|
||||
def customize_for_version3(self, version: tuple):
|
||||
def customize_for_version3(self, version):
|
||||
self.TABLE_DIRECT.update(
|
||||
{
|
||||
"comp_for": (" for %c in %c", (2, "store"), (0, "expr")),
|
||||
|
@@ -17,14 +17,14 @@
|
||||
|
||||
from xdis import co_flags_is_async, iscode
|
||||
|
||||
from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE, TABLE_DIRECT
|
||||
from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE
|
||||
from uncompyle6.semantics.helper import flatten_list, gen_function_parens_adjust
|
||||
|
||||
|
||||
#######################
|
||||
# Python 3.5+ Changes #
|
||||
#######################
|
||||
def customize_for_version35(self, version: tuple):
|
||||
def customize_for_version35(self, version):
|
||||
# fmt: off
|
||||
self.TABLE_DIRECT.update(
|
||||
{
|
||||
|
@@ -37,7 +37,7 @@ def escape_format(s):
|
||||
#######################
|
||||
|
||||
|
||||
def customize_for_version36(self, version: tuple):
|
||||
def customize_for_version36(self, version):
|
||||
# fmt: off
|
||||
PRECEDENCE["call_kw"] = 0
|
||||
PRECEDENCE["call_kw36"] = 1
|
||||
|
@@ -25,7 +25,7 @@ FSTRING_CONVERSION_MAP = {1: "!s", 2: "!r", 3: "!a", "X": ":X"}
|
||||
|
||||
|
||||
#######################
|
||||
def customize_for_version37(self, version: tuple):
|
||||
def customize_for_version37(self, version):
|
||||
########################
|
||||
# Python 3.7+ changes
|
||||
#######################
|
||||
|
@@ -19,12 +19,12 @@
|
||||
# Python 3.8+ changes
|
||||
#######################
|
||||
|
||||
from uncompyle6.semantics.consts import PRECEDENCE, TABLE_DIRECT
|
||||
from uncompyle6.semantics.consts import PRECEDENCE
|
||||
from uncompyle6.semantics.customize37 import FSTRING_CONVERSION_MAP
|
||||
from uncompyle6.semantics.helper import escape_string, strip_quotes
|
||||
|
||||
|
||||
def customize_for_version38(self, version: tuple):
|
||||
def customize_for_version38(self, version):
|
||||
# FIXME: pytest doesn't add proper keys in testing. Reinstate after we have fixed pytest.
|
||||
# for lhs in 'for forelsestmt forelselaststmt '
|
||||
# 'forelselaststmtc tryfinally38'.split():
|
||||
|
Reference in New Issue
Block a user