diff --git a/test/Makefile b/test/Makefile index 907bdac0..800e2929 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,4 +1,12 @@ -PHONY=check clean dist distclean test test-unit test-functional rmChangeLog clean_pyc nosetests +PHONY=check clean dist distclean test test-unit test-functional rmChangeLog clean_pyc nosetests \ + check-bytecode-1.5 check-bytecode-1 check-bytecode-2 check-bytecode-3 \ + check-bytecode-2.2 check-byteocde-2.3 check-bytecode-2.4 \ + check-short check-2.6 check-2.7 check-3.0 check-3.1 check-3.2 check-3.3 \ + check-3.4 check-3.5 check-5.6 5.6 5.8 \ + grammar-coverage-2.5 grammar-coverage-2.6 grammarcoverage-2.7 \ + grammar-coverage-3.1 grammar-coverage-3.2 grammarcoverage-3.3 \ + grammar-coverage-3.4 grammar-coverage-3.5 grammarcoverage-3.6 + GIT2CL ?= git2cl PYTHON ?= python @@ -59,8 +67,7 @@ check-disasm: $(PYTHON) dis-compare.py #: Check deparsing bytecode 1.x only -check-bytecode-1: - $(PYTHON) test_pythonlib.py --bytecode-1.5 +check-bytecode-1: check-bytecode-1.5 #: Check deparsing bytecode 2.x only check-bytecode-2: @@ -82,6 +89,10 @@ check-bytecode: check-bytecode-3 --bytecode-pypy2.7 --bytecode-1 +#: Check deparsing bytecode 1.5 only +check-bytecode-1.5: + $(PYTHON) test_pythonlib.py --bytecode-1.5 + #: Check deparsing Python 2.1 check-bytecode-2.1: $(PYTHON) test_pythonlib.py --bytecode-2.1 @@ -127,7 +138,8 @@ grammar-coverage-2.7: #: Get grammar coverage for Python 3.0 grammar-coverage-3.0: -rm $(COVER_DIR)/spark-grammar-32.cover - SPARK_PARSER_COVERAGE=$(COVER_DIR)/spark-grammar-30.cover $(PYTHON) test_pythonlib.py --bytecode-3.1 + +SPARK_PARSER_COVERAGE=$(COVER_DIR)/spark-grammar-30.cover $(PYTHON) test_pythonlib.py --bytecode-3.1 SPARK_PARSER_COVERAGE=$(COVER_DIR)/spark-grammar-30.cover $(PYTHON) test_pyenvlib.py --3.0.1 #: Get grammar coverage for Python 3.1 diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index b64665b0..e4bc760a 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -380,8 +380,8 @@ class PythonParser(GenericASTBuilder): def p_import20(self, args): """ stmt ::= import - stmt ::= importfrom - stmt ::= importstar + stmt ::= import_from + stmt ::= import_from_star stmt ::= importmultiple importlist ::= importlist alias @@ -390,10 +390,10 @@ class PythonParser(GenericASTBuilder): alias ::= IMPORT_FROM store alias ::= IMPORT_NAME load_attrs store - import ::= LOAD_CONST LOAD_CONST alias - importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR - importfrom ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP - importmultiple ::= LOAD_CONST LOAD_CONST alias imports_cont + import ::= LOAD_CONST LOAD_CONST alias + import_from_star ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR + import_from ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP + importmultiple ::= LOAD_CONST LOAD_CONST alias imports_cont imports_cont ::= import_cont+ import_cont ::= LOAD_CONST LOAD_CONST alias diff --git a/uncompyle6/parsers/parse15.py b/uncompyle6/parsers/parse15.py index 2a30466f..7a7183b6 100644 --- a/uncompyle6/parsers/parse15.py +++ b/uncompyle6/parsers/parse15.py @@ -13,14 +13,14 @@ class Python15Parser(Python21Parser): def p_import15(self, args): """ - import ::= filler IMPORT_NAME STORE_FAST - import ::= filler IMPORT_NAME STORE_NAME + import ::= filler IMPORT_NAME STORE_FAST + import ::= filler IMPORT_NAME STORE_NAME - importfrom ::= filler IMPORT_NAME importlist - importfrom ::= filler filler IMPORT_NAME importlist POP_TOP + import_from ::= filler IMPORT_NAME importlist + import_from ::= filler filler IMPORT_NAME importlist POP_TOP - importlist ::= importlist IMPORT_FROM - importlist ::= IMPORT_FROM + importlist ::= importlist IMPORT_FROM + importlist ::= IMPORT_FROM """ class Python15ParserSingle(Python21Parser, PythonParserSingle): diff --git a/uncompyle6/parsers/parse24.py b/uncompyle6/parsers/parse24.py index 99b177c7..39405301 100644 --- a/uncompyle6/parsers/parse24.py +++ b/uncompyle6/parsers/parse24.py @@ -26,9 +26,9 @@ class Python24Parser(Python25Parser): # 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import # keep positions similar to simplify semantic actions - import ::= filler LOAD_CONST alias - importfrom ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP - importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR + import ::= filler LOAD_CONST alias + import_from ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP + import_from_star ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR importmultiple ::= filler LOAD_CONST alias imports_cont import_cont ::= filler LOAD_CONST alias diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index c53c2166..beb3aad7 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -274,9 +274,9 @@ TABLE_DIRECT = { 'kv2': ( '%c: %c', 1, 2 ), 'import': ( '%|import %c\n', 2), 'importlist': ( '%C', (0, maxint, ', ') ), - 'importfrom': ( '%|from %[2]{pattr} import %c\n', + 'import_from': ( '%|from %[2]{pattr} import %c\n', (3, 'importlist') ), - 'importstar': ( '%|from %[2]{pattr} import *\n', ), + 'import_from_star': ( '%|from %[2]{pattr} import *\n', ), } diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index e40fd9e1..1d006a52 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1014,13 +1014,13 @@ class SourceWalker(GenericASTTraversal, object): self.write(iname, ' as ', sname) self.prune() # stop recursing - def n_importfrom(self, node): + def n_import_from(self, node): relative_path_index = 0 if self.version >= 2.5 and node[relative_path_index].pattr > 0: node[2].pattr = '.'*node[relative_path_index].pattr + node[2].pattr self.default(node) - n_importstar = n_importfrom + n_import_from_star = n_import_from def n_mkfunc(self, node):