You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix import and 3.x class bugs...
import x.y as z was failing across all Python versions class decorators for Python 3.0..3.3 was failing reduce 3.x while grammar rules
This commit is contained in:
BIN
test/bytecode_2.1/00_import.pyc
Normal file
BIN
test/bytecode_2.1/00_import.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.1/00_import.pyc
Normal file
BIN
test/bytecode_3.1/00_import.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.2/10_classdec.pyc
Normal file
BIN
test/bytecode_3.2/10_classdec.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
|
@@ -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):
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user