diff --git a/test/bytecode_2.1/00_import.pyc b/test/bytecode_2.1/00_import.pyc new file mode 100644 index 00000000..fed3667a Binary files /dev/null and b/test/bytecode_2.1/00_import.pyc differ diff --git a/test/bytecode_2.2/00_import.pyc b/test/bytecode_2.2/00_import.pyc index bccadb0c..3d9fbd01 100644 Binary files a/test/bytecode_2.2/00_import.pyc and b/test/bytecode_2.2/00_import.pyc differ diff --git a/test/bytecode_2.3/00_import.pyc b/test/bytecode_2.3/00_import.pyc index 6f7a4077..e2755523 100644 Binary files a/test/bytecode_2.3/00_import.pyc and b/test/bytecode_2.3/00_import.pyc differ diff --git a/test/bytecode_2.4/00_import.pyc b/test/bytecode_2.4/00_import.pyc index abf33a9e..b711ca9f 100644 Binary files a/test/bytecode_2.4/00_import.pyc and b/test/bytecode_2.4/00_import.pyc differ diff --git a/test/bytecode_2.5/00_import.pyc b/test/bytecode_2.5/00_import.pyc index c73f03f7..64e32f51 100644 Binary files a/test/bytecode_2.5/00_import.pyc and b/test/bytecode_2.5/00_import.pyc differ diff --git a/test/bytecode_2.6/00_import.pyc b/test/bytecode_2.6/00_import.pyc index da09e5d8..ec02a67b 100644 Binary files a/test/bytecode_2.6/00_import.pyc and b/test/bytecode_2.6/00_import.pyc differ diff --git a/test/bytecode_2.7/00_import.pyc b/test/bytecode_2.7/00_import.pyc index 2656c0b4..38f74f6b 100644 Binary files a/test/bytecode_2.7/00_import.pyc and b/test/bytecode_2.7/00_import.pyc differ diff --git a/test/bytecode_3.1/00_import.pyc b/test/bytecode_3.1/00_import.pyc new file mode 100644 index 00000000..cb446008 Binary files /dev/null and b/test/bytecode_3.1/00_import.pyc differ diff --git a/test/bytecode_3.2/00_import.pyc b/test/bytecode_3.2/00_import.pyc index a9b3648c..89ca5d6a 100644 Binary files a/test/bytecode_3.2/00_import.pyc and b/test/bytecode_3.2/00_import.pyc differ diff --git a/test/bytecode_3.2/10_classdec.pyc b/test/bytecode_3.2/10_classdec.pyc new file mode 100644 index 00000000..75d9e3bc Binary files /dev/null and b/test/bytecode_3.2/10_classdec.pyc differ diff --git a/test/bytecode_3.3/00_import.pyc b/test/bytecode_3.3/00_import.pyc index 78fe8206..6ffd1757 100644 Binary files a/test/bytecode_3.3/00_import.pyc and b/test/bytecode_3.3/00_import.pyc differ diff --git a/test/bytecode_3.4/00_import.pyc b/test/bytecode_3.4/00_import.pyc index db26ac84..4a455a04 100644 Binary files a/test/bytecode_3.4/00_import.pyc and b/test/bytecode_3.4/00_import.pyc differ diff --git a/test/bytecode_3.5/00_import.pyc b/test/bytecode_3.5/00_import.pyc index 1ced1b8c..b96f8054 100644 Binary files a/test/bytecode_3.5/00_import.pyc and b/test/bytecode_3.5/00_import.pyc differ diff --git a/test/bytecode_3.6/00_import.pyc b/test/bytecode_3.6/00_import.pyc index d8fdb5d6..c903cd67 100644 Binary files a/test/bytecode_3.6/00_import.pyc and b/test/bytecode_3.6/00_import.pyc differ diff --git a/test/simple_source/stmts/00_import.py b/test/simple_source/stmts/00_import.py index de00c442..eaee8271 100644 --- a/test/simple_source/stmts/00_import.py +++ b/test/simple_source/stmts/00_import.py @@ -1,6 +1,6 @@ # Tests: - import sys from os import path from os import * import time as time1, os as os1 +import http.client as httpclient diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 62908272..122e37c0 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -387,6 +387,7 @@ class PythonParser(GenericASTBuilder): importlist ::= import_as import_as ::= IMPORT_NAME store import_as ::= IMPORT_FROM store + import_as ::= IMPORT_NAME load_attrs store importstmt ::= LOAD_CONST LOAD_CONST import_as importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR @@ -395,6 +396,8 @@ class PythonParser(GenericASTBuilder): imports_cont ::= import_cont+ import_cont ::= LOAD_CONST LOAD_CONST import_as + + load_attrs ::= LOAD_ATTR+ """ def p_list_comprehension(self, args): diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 58cc5eee..ef3c5727 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -373,11 +373,6 @@ class Python3Parser(PythonParser): whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM_LOOP - # The JUMP_ABSOLUTE below comes from escaping an "if" block which surrounds - # the while. This is messy - whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK - JUMP_ABSOLUTE COME_FROM_LOOP - whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP diff --git a/uncompyle6/parsers/parse33.py b/uncompyle6/parsers/parse33.py index 4a40b741..e7f3482b 100644 --- a/uncompyle6/parsers/parse33.py +++ b/uncompyle6/parsers/parse33.py @@ -18,9 +18,6 @@ class Python33Parser(Python32Parser): # We do the grammar hackery below for semantics # actions that want c_stmts_opt at index 1 - whileTruestmt ::= SETUP_LOOP l_stmts JUMP_ABSOLUTE - JUMP_BACK COME_FROM_LOOP - # Python 3.5+ has jump optimization to remove the redundant # jump_excepts. But in 3.3 we need them added @@ -33,11 +30,8 @@ class Python33Parser(Python32Parser): def add_custom_rules(self, tokens, customize): self.remove_rules(""" # 3.3+ adds POP_BLOCKS - whileTruestmt ::= SETUP_LOOP l_stmts JUMP_ABSOLUTE JUMP_BACK COME_FROM_LOOP whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP - whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK - POP_BLOCK JUMP_ABSOLUTE COME_FROM_LOOP """) super(Python33Parser, self).add_custom_rules(tokens, customize) return diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 2be32c8b..b0a2abfe 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1434,6 +1434,8 @@ class SourceWalker(GenericASTTraversal, object): if node == 'classdefdeco2': if self.version >= 3.6: class_name = node[1][1].pattr + elif self.version <= 3.3: + class_name = node[2][0].pattr else: class_name = node[1][2].pattr buildclass = node