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.

classification
Title: while False: break => SyntaxError: 'break' outside loop
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jabesq, miss-islington, pablogsal, serhiy.storchaka
Priority: normal Keywords: 3.8regression, patch

Created on 2019-10-30 09:48 by jabesq, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16992 merged pablogsal, 2019-10-30 11:24
PR 16993 merged miss-islington, 2019-10-30 11:53
Messages (4)
msg355700 - (view) Author: Hugo Dupras (jabesq) Date: 2019-10-30 09:48
In python 3.8 the following code raises an exception, which was not the case with previous python.

```
while False:
    ...
    break
```
It raises the following exception: SyntaxError: 'break' outside loop.
This `while False` loop was used to temporary disable a while loop in our code base.

Workaround to fix this:
```
enable=False
while enable:
    ...
    break
``` (or use the walrus operator)
msg355709 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-10-30 11:53
New changeset 6c3e66a34b95fff07df0ad5086104dd637a091ce by Pablo Galindo in branch 'master':
bpo-38640: Allow break and continue in always false while loops (GH-16992)
https://github.com/python/cpython/commit/6c3e66a34b95fff07df0ad5086104dd637a091ce
msg355710 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-10-30 11:57
Thanks, Hugo Dupras for the report! :)
msg355711 - (view) Author: miss-islington (miss-islington) Date: 2019-10-30 12:11
New changeset dcb338ea1b8f14e21dde3564658b9040df996349 by Miss Skeleton (bot) in branch '3.8':
bpo-38640: Allow break and continue in always false while loops (GH-16992)
https://github.com/python/cpython/commit/dcb338ea1b8f14e21dde3564658b9040df996349
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82821
2019-12-10 10:57:50serhiy.storchakalinkissue39013 superseder
2019-10-30 12:11:44miss-islingtonsetnosy: + miss-islington
messages: + msg355711
2019-10-30 11:57:25pablogsalsetstatus: open -> closed
resolution: fixed
messages: + msg355710

stage: patch review -> resolved
2019-10-30 11:53:39miss-islingtonsetpull_requests: + pull_request16519
2019-10-30 11:53:29pablogsalsetmessages: + msg355709
2019-10-30 11:24:15pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16518
2019-10-30 10:17:43serhiy.storchakasetkeywords: + 3.8regression
nosy: + serhiy.storchaka, pablogsal
2019-10-30 09:48:06jabesqcreate