Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a while loop can have multiple jump_back's #60

Open
rocky opened this issue Jan 28, 2019 · 0 comments
Open

a while loop can have multiple jump_back's #60

rocky opened this issue Jan 28, 2019 · 0 comments

Comments

@rocky
Copy link

rocky commented Jan 28, 2019

# Bug in Python 2.7. Bug is bytecode for while loop having
# two consecutive JUMP_BACKS at the end of 'elif' and 'while'
# to the same place
def PreprocessConditionalStatement(self, IfList, ReplacedLine):
    while self:
        if self.__Token:
            x = 1
        elif not IfList:
            if self <= 2:
                continue
            RegionSizeGuid = 3
            if not RegionSizeGuid:
                RegionLayoutLine = 5
                continue
            RegionLayoutLine = self.CurrentLineNumber
    return 1

when compiled and decompiled gives:

$ uncompyle2 bytecode_2.7/05_while_elif.pyc 
# 2019.01.27 21:47:39 EST
#Embedded file name: simple_source/bug27+/05_while_elif.py


def PreprocessConditionalStatement--- This code section failed: ---

0	SETUP_LOOP        '91'
3	LOAD_FAST         'self'
6	POP_JUMP_IF_FALSE '90'

9	LOAD_FAST         'self'
12	LOAD_ATTR         '__Token'
15	POP_JUMP_IF_FALSE '27'

18	LOAD_CONST        1
21	STORE_FAST        'x'
24	JUMP_BACK         '3'

27	LOAD_FAST         'IfList'
30	POP_JUMP_IF_TRUE  '3'

33	LOAD_FAST         'self'
36	LOAD_CONST        2
39	COMPARE_OP        '<='
42_0	COME_FROM         '30'
42	POP_JUMP_IF_FALSE '51'

45	CONTINUE          '3'
48	JUMP_FORWARD      '51'
51_0	COME_FROM         '48'

51	LOAD_CONST        3
54	STORE_FAST        'RegionSizeGuid'

57	LOAD_FAST         'RegionSizeGuid'
60	POP_JUMP_IF_TRUE  '75'

63	LOAD_CONST        5
66	STORE_FAST        'RegionLayoutLine'

69	CONTINUE          '3'
72	JUMP_FORWARD      '75'
75_0	COME_FROM         '72'

75	LOAD_FAST         'self'
78	LOAD_ATTR         'CurrentLineNumber'
81	STORE_FAST        'RegionLayoutLine'
84	JUMP_BACK         '3'
87	JUMP_BACK         '3'
90	POP_BLOCK         None
91_0	COME_FROM         '0'

91	LOAD_CONST        1
94	RETURN_VALUE      None
-1	RETURN_LAST       None

Syntax error at or near `JUMP_BACK' token at offset 87
### Can't uncompyle bytecode_2.7/05_while_elif.pyc
Traceback (most recent call last):
  File "/src/external-vcs/github/uncompyle2-wibiti/uncompyle2/__init__.py", line 197, in main
    uncompyle_file(infile, outstream, showasm, showast, deob)
  File "/src/external-vcs/github/uncompyle2-wibiti/uncompyle2/__init__.py", line 130, in uncompyle_file
    uncompyle(version, co, outstream, showasm, showast, deob)
  File "/src/external-vcs/github/uncompyle2-wibiti/uncompyle2/__init__.py", line 123, in uncompyle
    raise walker.ERROR
ParserError: --- This code section failed: ---

0	SETUP_LOOP        '91'
3	LOAD_FAST         'self'
6	POP_JUMP_IF_FALSE '90'

9	LOAD_FAST         'self'
12	LOAD_ATTR         '__Token'
15	POP_JUMP_IF_FALSE '27'

18	LOAD_CONST        1
21	STORE_FAST        'x'
24	JUMP_BACK         '3'

27	LOAD_FAST         'IfList'
30	POP_JUMP_IF_TRUE  '3'

33	LOAD_FAST         'self'
36	LOAD_CONST        2
39	COMPARE_OP        '<='
42_0	COME_FROM         '30'
42	POP_JUMP_IF_FALSE '51'

45	CONTINUE          '3'
48	JUMP_FORWARD      '51'
51_0	COME_FROM         '48'

51	LOAD_CONST        3
54	STORE_FAST        'RegionSizeGuid'

57	LOAD_FAST         'RegionSizeGuid'
60	POP_JUMP_IF_TRUE  '75'

63	LOAD_CONST        5
66	STORE_FAST        'RegionLayoutLine'

69	CONTINUE          '3'
72	JUMP_FORWARD      '75'
75_0	COME_FROM         '72'

75	LOAD_FAST         'self'
78	LOAD_ATTR         'CurrentLineNumber'
81	STORE_FAST        'RegionLayoutLine'
84	JUMP_BACK         '3'
87	JUMP_BACK         '3'
90	POP_BLOCK         None
91_0	COME_FROM         '0'

91	LOAD_CONST        1
94	RETURN_VALUE      None
-1	RETURN_LAST       None

Syntax error at or near `JUMP_BACK' token at offset 87
# decompiled 0 files: 0 okay, 1 failed, 0 verify failed
# 2019.01.27 21:47:39 EST

rocky/python-uncompyle6@bfceeac can probably be adapted. See also that project for the source file and 2.7 bytecode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant