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

Error with break inside nested for loop #323

Open
ghost opened this issue Jun 29, 2020 · 1 comment
Open

Error with break inside nested for loop #323

ghost opened this issue Jun 29, 2020 · 1 comment
Labels
control flow Python 3.8 volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3

Comments

@ghost
Copy link

ghost commented Jun 29, 2020

This code fails to decompile under python3.8:

for x in arr_a:
    for y in arr_b:
        var = True
        break

Bytecode:

  1           0 LOAD_NAME                0 (arr_a)
              2 GET_ITER
        >>    4 FOR_ITER                22 (to 28)
              6 STORE_NAME               1 (x)

  2           8 LOAD_NAME                2 (arr_b)
             10 GET_ITER
        >>   12 FOR_ITER                12 (to 26)
             14 STORE_NAME               3 (y)

  3          16 LOAD_CONST               0 (True)
             18 STORE_NAME               4 (var)

  4          20 POP_TOP
             22 JUMP_ABSOLUTE            4
             24 JUMP_ABSOLUTE           12
        >>   26 JUMP_ABSOLUTE            4
        >>   28 LOAD_CONST               1 (None)
             30 RETURN_VALUE

Error:

# uncompyle6 version 3.7.2
# Python bytecode 3.8 (3413)
# Decompiled from: Python 3.8.3 (default, May 14 2020, 11:03:12) 
# [GCC 9.3.0]
# Embedded file name: ./code.py
# Compiled at: 2020-06-29 18:58:01
# Size of source mod 2**32: 69 bytes
Instruction context:
   
 L.   4        20  POP_TOP          
->                22  CONTINUE              4  'to 4'
                  24  JUMP_BACK            12  'to 12'


# file __pycache__/code.cpython-38.pyc
# --- This code section failed: ---

 L.   1         0  LOAD_NAME                arr_a
                2  GET_ITER         
                4  FOR_ITER             28  'to 28'
                6  STORE_NAME               x

 L.   2         8  LOAD_NAME                arr_b
               10  GET_ITER         
               12  FOR_ITER             26  'to 26'
               14  STORE_NAME               y

 L.   3        16  LOAD_CONST               True
               18  STORE_NAME               var

 L.   4        20  POP_TOP          
               22  CONTINUE              4  'to 4'
               24  JUMP_BACK            12  'to 12'
               26  JUMP_BACK             4  'to 4'

Parse error at or near `CONTINUE' instruction at offset 22

This seems to be caused by the 'break' being recognised as a 'continue'?

@rocky rocky added control flow Python 3.8 volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. labels Jun 29, 2020
@rocky
Copy link
Owner

rocky commented Jun 29, 2020

You'll find lots of problems like this in 3.8. Probably even more in 3.9.

For myself, I don't see myself working on 3.8 and 3.9 until I can find finding for this work.

This works on decompyle3 so someone can try backporting that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control flow Python 3.8 volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3
Projects
None yet
Development

No branches or pull requests

1 participant