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: SyntaxError: 'break' outside loop for legal Expression
Type: compile error Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: while False: break => SyntaxError: 'break' outside loop
View: 38640
Assigned To: Nosy List: Artem Tepanov, steven.daprano, xtreak
Priority: normal Keywords:

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

Messages (7)
msg358175 - (view) Author: Artem Tepanov (Artem Tepanov) Date: 2019-12-10 09:48
Why I can't execute this code:

while False:
    if False:
        break
print('WTF?')
When I use repl.it or PyCharm on my work (Python 3.7) all works fine, yes I know this code looks silly, but it is a legal expression.

About CPython Interpreter:
C:\WINDOWS\system32>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
msg358176 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-12-10 09:56
I don't know, why *can't* you execute that code? It works fine for me. Although I'm not using the exact same version of 3.8 that you are using.

Could you copy and paste (not a screen shot or photo!) the text of your interactive session, including the error that you get, please?
msg358177 - (view) Author: Artem Tepanov (Artem Tepanov) Date: 2019-12-10 10:40
Using cmd:
C:\Users\ATepanov>python -V
Python 3.8.0

C:\Users\ATepanov>python C:\Users\ATepanov\Desktop\Outside_The_Loop.py
  File "C:\Users\ATepanov\Desktop\Outside_The_Loop.py", line 3
    break
    ^
SyntaxError: 'break' outside loop


In Interactive:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> while False:
...     break
...
  File "<stdin>", line 2
SyntaxError: 'break' outside loop
>>>
msg358178 - (view) Author: Artem Tepanov (Artem Tepanov) Date: 2019-12-10 10:44
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> while False:
...     if False:
...         break
...
  File "<stdin>", line 3
SyntaxError: 'break' outside loop
msg358179 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-12-10 10:49
This seems to be same as issue38640 . Can you please try 3.8.1RC1 to see if it's fixed?

https://www.python.org/downloads/release/python-381rc1/
msg358180 - (view) Author: Artem Tepanov (Artem Tepanov) Date: 2019-12-10 11:07
Thx, after upgrade to:
Python 3.8.1rc1 (tags/v3.8.1rc1:b00a2b5, Dec 10 2019, 01:13:53) [MSC v.1916 64 bit (AMD64)] on win32
All works fine,
...but Could you "pushing the person" which responsible for Web-Site please?, because I got Interpreter from there: https://www.python.org/downloads/release/python-380/

Without any Warnings or Recommendation for using 3.8.1rc1

Is it normal?
msg358183 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-12-10 12:07
Thanks for the confirmation. The issue was found after 3.8.0 release. The fix is in 3.8.1RC1 and will be made as 3.8.1 in couple of weeks. Normally regressions are not listed at downloads page but are tagged as regression in the tracker like the one linked. You can wait for sometime to use 3.8.1 which should fix the issue.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83194
2019-12-10 12:07:15xtreaksetmessages: + msg358183
2019-12-10 11:07:07Artem Tepanovsetmessages: + msg358180
2019-12-10 10:57:50serhiy.storchakasetstatus: open -> closed
superseder: while False: break => SyntaxError: 'break' outside loop
resolution: duplicate
stage: resolved
2019-12-10 10:49:47xtreaksetnosy: + xtreak
messages: + msg358179
2019-12-10 10:44:15Artem Tepanovsetmessages: + msg358178
2019-12-10 10:40:23Artem Tepanovsetmessages: + msg358177
2019-12-10 09:56:00steven.dapranosetnosy: + steven.daprano
messages: + msg358176
2019-12-10 09:48:48Artem Tepanovcreate