This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients BTaskaya, Mark.Shannon, eric.smith, serhiy.storchaka, xtreak
Date 2019-08-12.11:32:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565609562.21.0.624533424218.issue37830@roundup.psfhosted.org>
In-reply-to
Content
Thank you for your report Batuhan.

But PR 15221 is not proper way to fix it. It will not work when return an iterable. This issue should be fixed at compiler level. The generated code is:

Disassembly of <code object simple at 0x7f2195c7d450, file "<stdin>", line 1>:
  2           0 LOAD_GLOBAL              0 (range)
              2 LOAD_CONST               1 (2)
              4 CALL_FUNCTION            1
              6 GET_ITER
        >>    8 FOR_ITER                24 (to 34)
             10 STORE_FAST               0 (number)

  3          12 SETUP_FINALLY           12 (to 26)

  4          14 LOAD_FAST                0 (number)
             16 POP_BLOCK
             18 CALL_FINALLY             6 (to 26)
             20 ROT_TWO
             22 POP_TOP
             24 RETURN_VALUE

  6     >>   26 POP_FINALLY              0
             28 JUMP_ABSOLUTE            8
             30 END_FINALLY
             32 JUMP_ABSOLUTE            8
        >>   34 LOAD_CONST               0 (None)
             36 RETURN_VALUE

The return statement pushes a value at the stack (offset 14) and the continue statement jumps to the beginning of the loop (offset 28). The stack is not balanced here.
History
Date User Action Args
2019-08-12 11:32:42serhiy.storchakasetrecipients: + serhiy.storchaka, eric.smith, Mark.Shannon, xtreak, BTaskaya
2019-08-12 11:32:42serhiy.storchakasetmessageid: <1565609562.21.0.624533424218.issue37830@roundup.psfhosted.org>
2019-08-12 11:32:42serhiy.storchakalinkissue37830 messages
2019-08-12 11:32:41serhiy.storchakacreate