You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
NT importfrom -> import_from ...
to match AST better and importstar -> import_from_star misc administrivia
This commit is contained in:
@@ -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
|
GIT2CL ?= git2cl
|
||||||
PYTHON ?= python
|
PYTHON ?= python
|
||||||
@@ -59,8 +67,7 @@ check-disasm:
|
|||||||
$(PYTHON) dis-compare.py
|
$(PYTHON) dis-compare.py
|
||||||
|
|
||||||
#: Check deparsing bytecode 1.x only
|
#: Check deparsing bytecode 1.x only
|
||||||
check-bytecode-1:
|
check-bytecode-1: check-bytecode-1.5
|
||||||
$(PYTHON) test_pythonlib.py --bytecode-1.5
|
|
||||||
|
|
||||||
#: Check deparsing bytecode 2.x only
|
#: Check deparsing bytecode 2.x only
|
||||||
check-bytecode-2:
|
check-bytecode-2:
|
||||||
@@ -82,6 +89,10 @@ check-bytecode: check-bytecode-3
|
|||||||
--bytecode-pypy2.7 --bytecode-1
|
--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 deparsing Python 2.1
|
||||||
check-bytecode-2.1:
|
check-bytecode-2.1:
|
||||||
$(PYTHON) test_pythonlib.py --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
|
#: Get grammar coverage for Python 3.0
|
||||||
grammar-coverage-3.0:
|
grammar-coverage-3.0:
|
||||||
-rm $(COVER_DIR)/spark-grammar-32.cover
|
-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
|
SPARK_PARSER_COVERAGE=$(COVER_DIR)/spark-grammar-30.cover $(PYTHON) test_pyenvlib.py --3.0.1
|
||||||
|
|
||||||
#: Get grammar coverage for Python 3.1
|
#: Get grammar coverage for Python 3.1
|
||||||
|
@@ -380,8 +380,8 @@ class PythonParser(GenericASTBuilder):
|
|||||||
def p_import20(self, args):
|
def p_import20(self, args):
|
||||||
"""
|
"""
|
||||||
stmt ::= import
|
stmt ::= import
|
||||||
stmt ::= importfrom
|
stmt ::= import_from
|
||||||
stmt ::= importstar
|
stmt ::= import_from_star
|
||||||
stmt ::= importmultiple
|
stmt ::= importmultiple
|
||||||
|
|
||||||
importlist ::= importlist alias
|
importlist ::= importlist alias
|
||||||
@@ -390,10 +390,10 @@ class PythonParser(GenericASTBuilder):
|
|||||||
alias ::= IMPORT_FROM store
|
alias ::= IMPORT_FROM store
|
||||||
alias ::= IMPORT_NAME load_attrs store
|
alias ::= IMPORT_NAME load_attrs store
|
||||||
|
|
||||||
import ::= LOAD_CONST LOAD_CONST alias
|
import ::= LOAD_CONST LOAD_CONST alias
|
||||||
importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR
|
import_from_star ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||||
importfrom ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP
|
import_from ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP
|
||||||
importmultiple ::= LOAD_CONST LOAD_CONST alias imports_cont
|
importmultiple ::= LOAD_CONST LOAD_CONST alias imports_cont
|
||||||
|
|
||||||
imports_cont ::= import_cont+
|
imports_cont ::= import_cont+
|
||||||
import_cont ::= LOAD_CONST LOAD_CONST alias
|
import_cont ::= LOAD_CONST LOAD_CONST alias
|
||||||
|
@@ -13,14 +13,14 @@ class Python15Parser(Python21Parser):
|
|||||||
|
|
||||||
def p_import15(self, args):
|
def p_import15(self, args):
|
||||||
"""
|
"""
|
||||||
import ::= filler IMPORT_NAME STORE_FAST
|
import ::= filler IMPORT_NAME STORE_FAST
|
||||||
import ::= filler IMPORT_NAME STORE_NAME
|
import ::= filler IMPORT_NAME STORE_NAME
|
||||||
|
|
||||||
importfrom ::= filler IMPORT_NAME importlist
|
import_from ::= filler IMPORT_NAME importlist
|
||||||
importfrom ::= filler filler IMPORT_NAME importlist POP_TOP
|
import_from ::= filler filler IMPORT_NAME importlist POP_TOP
|
||||||
|
|
||||||
importlist ::= importlist IMPORT_FROM
|
importlist ::= importlist IMPORT_FROM
|
||||||
importlist ::= IMPORT_FROM
|
importlist ::= IMPORT_FROM
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Python15ParserSingle(Python21Parser, PythonParserSingle):
|
class Python15ParserSingle(Python21Parser, PythonParserSingle):
|
||||||
|
@@ -26,9 +26,9 @@ class Python24Parser(Python25Parser):
|
|||||||
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
||||||
# keep positions similar to simplify semantic actions
|
# keep positions similar to simplify semantic actions
|
||||||
|
|
||||||
import ::= filler LOAD_CONST alias
|
import ::= filler LOAD_CONST alias
|
||||||
importfrom ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP
|
import_from ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP
|
||||||
importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
|
import_from_star ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||||
|
|
||||||
importmultiple ::= filler LOAD_CONST alias imports_cont
|
importmultiple ::= filler LOAD_CONST alias imports_cont
|
||||||
import_cont ::= filler LOAD_CONST alias
|
import_cont ::= filler LOAD_CONST alias
|
||||||
|
@@ -274,9 +274,9 @@ TABLE_DIRECT = {
|
|||||||
'kv2': ( '%c: %c', 1, 2 ),
|
'kv2': ( '%c: %c', 1, 2 ),
|
||||||
'import': ( '%|import %c\n', 2),
|
'import': ( '%|import %c\n', 2),
|
||||||
'importlist': ( '%C', (0, maxint, ', ') ),
|
'importlist': ( '%C', (0, maxint, ', ') ),
|
||||||
'importfrom': ( '%|from %[2]{pattr} import %c\n',
|
'import_from': ( '%|from %[2]{pattr} import %c\n',
|
||||||
(3, 'importlist') ),
|
(3, 'importlist') ),
|
||||||
'importstar': ( '%|from %[2]{pattr} import *\n', ),
|
'import_from_star': ( '%|from %[2]{pattr} import *\n', ),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1014,13 +1014,13 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.write(iname, ' as ', sname)
|
self.write(iname, ' as ', sname)
|
||||||
self.prune() # stop recursing
|
self.prune() # stop recursing
|
||||||
|
|
||||||
def n_importfrom(self, node):
|
def n_import_from(self, node):
|
||||||
relative_path_index = 0
|
relative_path_index = 0
|
||||||
if self.version >= 2.5 and node[relative_path_index].pattr > 0:
|
if self.version >= 2.5 and node[relative_path_index].pattr > 0:
|
||||||
node[2].pattr = '.'*node[relative_path_index].pattr + node[2].pattr
|
node[2].pattr = '.'*node[relative_path_index].pattr + node[2].pattr
|
||||||
self.default(node)
|
self.default(node)
|
||||||
|
|
||||||
n_importstar = n_importfrom
|
n_import_from_star = n_import_from
|
||||||
|
|
||||||
def n_mkfunc(self, node):
|
def n_mkfunc(self, node):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user