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

while False: break => SyntaxError: 'break' outside loop #82821

Closed
jabesq mannequin opened this issue Oct 30, 2019 · 4 comments
Closed

while False: break => SyntaxError: 'break' outside loop #82821

jabesq mannequin opened this issue Oct 30, 2019 · 4 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@jabesq
Copy link
Mannequin

jabesq mannequin commented Oct 30, 2019

BPO 38640
Nosy @serhiy-storchaka, @pablogsal, @miss-islington, @jabesq
PRs
  • bpo-38640: Allow break and continue in always false while loops #16992
  • [3.8] bpo-38640: Allow break and continue in always false while loops (GH-16992) #16993
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-10-30.11:57:25.555>
    created_at = <Date 2019-10-30.09:48:06.482>
    labels = ['interpreter-core', 'type-bug', '3.8']
    title = "while False: break => SyntaxError: 'break' outside loop"
    updated_at = <Date 2019-10-30.12:11:44.135>
    user = 'https://github.com/jabesq'

    bugs.python.org fields:

    activity = <Date 2019-10-30.12:11:44.135>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-10-30.11:57:25.555>
    closer = 'pablogsal'
    components = ['Interpreter Core']
    creation = <Date 2019-10-30.09:48:06.482>
    creator = 'jabesq'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38640
    keywords = ['patch', '3.8regression']
    message_count = 4.0
    messages = ['355700', '355709', '355710', '355711']
    nosy_count = 4.0
    nosy_names = ['serhiy.storchaka', 'pablogsal', 'miss-islington', 'jabesq']
    pr_nums = ['16992', '16993']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38640'
    versions = ['Python 3.8']

    @jabesq
    Copy link
    Mannequin Author

    jabesq mannequin commented Oct 30, 2019

    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)
    

    @jabesq jabesq mannequin added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Oct 30, 2019
    @pablogsal
    Copy link
    Member

    New changeset 6c3e66a by Pablo Galindo in branch 'master':
    bpo-38640: Allow break and continue in always false while loops (GH-16992)
    6c3e66a

    @pablogsal
    Copy link
    Member

    Thanks, Hugo Dupras for the report! :)

    @miss-islington
    Copy link
    Contributor

    New changeset dcb338e by Miss Skeleton (bot) in branch '3.8':
    bpo-38640: Allow break and continue in always false while loops (GH-16992)
    dcb338e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants