Mysterie / uncompyle2

uncompyle2
642 stars 148 forks source link

Unable to decompile this simple code #4

Closed starportx closed 11 years ago

starportx commented 11 years ago

First of all I must admit this decompiler is the best I've ever tested, great readality and debuggable, nice work, guys! But here is a very simple section that current build can't pass through, I don't know a lof on byte-code, but I believe it's a bug, any question please contact me in: jarodfeng@ea.com

source:

selection = []
allEdges2

def findVerts( selection ):
    allEdges2 = ['AAA', 'BBB', 'CCC']
    templates2 = ['A', 'B', 'C']
    cdEdgeLength2 = [floorMe( e.lower() ) for e in allEdges2]
    for i in range( len( templates2 ) ):
        if cdEdgeLength2[0] == templates2[i] :
            if selection:
                selection.append( e.lower() )

def floorMe( stringX ):
    return stringX

asm:

def findVerts--- This code section failed: ---

0   LOAD_CONST        'AAA'
3   LOAD_CONST        'BBB'
6   LOAD_CONST        'CCC'
9   BUILD_LIST_3      None
12  STORE_FAST        'allEdges2'

15  LOAD_CONST        'A'
18  LOAD_CONST        'B'
21  LOAD_CONST        'C'
24  BUILD_LIST_3      None
27  STORE_FAST        'templates2'

30  BUILD_LIST_0      None
33  LOAD_FAST         'allEdges2'
36  GET_ITER          None
37  FOR_ITER          '62'
40  STORE_FAST        'e'
43  LOAD_GLOBAL       'floorMe'
46  LOAD_FAST         'e'
49  LOAD_ATTR         'lower'
52  CALL_FUNCTION_0   None
55  CALL_FUNCTION_1   None
58  LIST_APPEND       None
59  JUMP_BACK         '37'
62  STORE_FAST        'cdEdgeLength2'

65  SETUP_LOOP        '142'
68  LOAD_GLOBAL       'range'
71  LOAD_GLOBAL       'len'
74  LOAD_FAST         'templates2'
77  CALL_FUNCTION_1   None
80  CALL_FUNCTION_1   None
83  GET_ITER          None
84  FOR_ITER          '141'
87  STORE_FAST        'i'

90  LOAD_FAST         'cdEdgeLength2'
93  LOAD_CONST        0
96  BINARY_SUBSCR     None
97  LOAD_FAST         'templates2'
100 LOAD_FAST         'i'
103 BINARY_SUBSCR     None
104 COMPARE_OP        '=='
107 JUMP_IF_FALSE     '84'

110 LOAD_FAST         'selection'
113 JUMP_IF_FALSE     '138'

116 LOAD_FAST         'selection'
119 LOAD_ATTR         'append'
122 LOAD_FAST         'e'
125 LOAD_ATTR         'lower'
128 CALL_FUNCTION_0   None
131 CALL_FUNCTION_1   None
134 POP_TOP           None
135 JUMP_ABSOLUTE     '138'
138 JUMP_BACK         '84'
141 POP_BLOCK         None
142_0   COME_FROM         '65'

Syntax error at or near `POP_BLOCK' token at offset 141

def floorMe(stringX):
    return stringX
Mysterie commented 11 years ago

Thank you! With the source code it's easier for me. You're right it's a bug, and an interesting one!

In fact when this code is compiled, the bytecode generated contain a special opcode named LIST_APPEND. In the python bytecode version 2.5 & 2.6 the LIST_APPEND opcode is one octet sized. But in 2.7 LIST_APPEND is three octets size (it has an argument).

I'll patch my code for handling this change in the different version of python bytecode. Sorry for my lagy answer btw. Patch will come soon. :)

starportx commented 11 years ago

It’s really nice to hear that, thank you for your support! You and your compiler are the best!

From: Mysterie [mailto:notifications@github.com] Sent: Thursday, December 13, 2012 7:58 PM To: Mysterie/uncompyle2 Cc: Feng, Yixuan (Jarod) Subject: Re: [uncompyle2] Unable to decompile this simple code (#4)

Thank you! With the source code it's easier for me. You're right it's a bug, and an interesting one!

In fact when this code is compiled, the bytecode generated contain a special opcode named LIST_APPEND. In the python bytecode version 2.5 & 2.6 the LIST_APPEND opcode is one octet sized. But in 2.7 LIST_APPEND is three octets size (it has an argument).

I'll patch my code for handling this change in the different version of python bytecode. Sorry for my lagy answer btw. Patch will come soon. :)

— Reply to this email directly or view it on GitHubhttps://github.com/Mysterie/uncompyle2/issues/4#issuecomment-11331931.