GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unhelpful `SyntaxError` with unclosed call before colon · Issue #94034 · python/cpython

Unhelpful SyntaxError with unclosed call before colon #94034

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Unhelpful SyntaxError with unclosed call before colon#94034
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@brandtbucher
brandtbucher
opened on Jun 20, 2022
Issue body actions

Ran into this today. If you forget to close parentheses as part of a call in the header of a for, with, or class statement (maybe others too?), the SyntaxError seems to indicate that you forgot a colon:

>>> for foo in bar(baz:
  File "<stdin>", line 1
    for foo in bar(baz:
                  ^
SyntaxError: expected ':'

It's not wrong, but could probably be improved. I personally find the pre-3.10 behavior more helpful:

>>> bar(baz:
  File "<stdin>", line 1
    for foo in bar(baz:
                      ^
SyntaxError: invalid syntax

Even better, though, would be a "smarter" error message like the existing ones we have for unclosed parentheses:

>>> bar(baz:
  File "<stdin>", line 1
    for foo in bar(baz:
                  ^
SyntaxError: '(' was never closed

@pablogsal

Activity

  1. brandtbucher
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.11only security fixesonly security fixes
    3.10 (EOL)end of lifeend of life
    3.12only security fixesonly security fixes
    on Jun 20, 2022
  2. pablogsal commented on Jun 20, 2022

    @pablogsal
    pablogsal
    on Jun 20, 2022
    Member
    More actions

    I think this will be fixed by #92894 (comment). @brandtbucher can you check (I'm away from the keyboard right now)? Otherwise I will do it later today :)

  3. brandtbucher
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Jun 20, 2022
  4. brandtbucher commented on Jun 20, 2022

    @brandtbucher
    brandtbucher
    on Jun 20, 2022
    MemberAuthor
    More actions

    Looks like it might be. At any rate, I'll close this as a duplicate of #92858.

  5. brandtbucher
    closed this as not plannedon Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.