Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ConfusingSyntaxError message forx for x if range(1) #111488

Closed
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or error
@sobolevn

Description

@sobolevn

Bug report

Today I made a typo: instead ofin I wroteif.
I was quite interested to see the error message:

>>> [xforxifrange(1)]File"<stdin>",line1    [xforxifrange(1)]^^^^^^^^^^^^^SyntaxError:expected'else'after'if'expression

I don't think that this error message is correct. Why? Because even if we follow the rabbit hole and useelse, we won't be ever correct:

>>> [xfor (xifrange(1)elsey)inrange(1)]File"<stdin>",line1    [xfor (xifrange(1)elsey)inrange(1)]^^^^^^^^^^^^^^^^^^^^SyntaxError:cannotassigntoconditionalexpression

So, maybe we should change it to be something like:

>>> [xforxifrange(1)]File"<stdin>",line1    [xforxifrange(1)]^^SyntaxError:expected'in',got'if'

Suggestions about wording are welcome :)

If others agree, I would like to work on this.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp