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 — Inconsistency between file names of SyntaxErrors and other Exceptions in the new repl · Issue #122546 · python/cpython

Inconsistency between file names of SyntaxErrors and other Exceptions in the new repl #122546

New issue
Copy link
New issue
Copy link
Closed
Closed
Inconsistency between file names of SyntaxErrors and other Exceptions in the new repl#122546
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-replRelated to the interactive shellRelated to the interactive shell

Description

@cfbolz
cfbolz
opened on Aug 1, 2024
Issue body actions

A small issue, but the new repl reports <unknown> as the file name for SyntaxErrors, but <python-input-x> for other errors:

>>> a b c
  File "<unknown>", line 1
    a b c
      ^
SyntaxError: invalid syntax
>>> 1 / 0
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    1 / 0
    ~~^~~
ZeroDivisionError: division by zero

Classic repl:

>>> a b c
  File "<stdin>", line 1
    a b c
      ^
SyntaxError: invalid syntax
>>> a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    a
NameError: name 'a' is not defined
>>> 

I think this is because _pyrepl.console.InteractiveColoredConsole.showsyntaxerror does not pass on the filename argument to the super method:

    def showsyntaxerror(self, filename=None):
        super().showsyntaxerror(colorize=self.can_colorize)

Should probably wait till #122528 is done. Then, InteractiveColoredConsole could be simplified to overwrite only _showtraceback. The undocumented colorize keyword arguments that showtraceback and showsyntaxerror have gained for pyrepl could be removed again.

Linked PRs

  • gh-122546: use same filename for different exceptions in new repl #123217
  • [3.13] gh-122546: use same filename for different exceptions in new repl (GH-123217) #123226
  • gh-122546: Relax SyntaxError check when raising errors on the new REPL #123233
  • [3.13] gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH-123233) #123246
  • [3.13] gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH-123233) #123247

Activity

  1. Eclips4
    added
    topic-replRelated to the interactive shellRelated to the interactive shell
    on Aug 1, 2024
  2. AlexWaygood
    added
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Aug 1, 2024
  3. skirpichev
    added a commit that references this issue on Aug 22, 2024

    pythongh-122546: use same filename for different exceptions in new repl

    4b6795b
  4. skirpichev commented on Aug 22, 2024

    @skirpichev
    skirpichev
    on Aug 22, 2024
    Member
    More actions

    pr is ready: #123217

  5. pablogsal
    added a commit that references this issue on Aug 22, 2024

    gh-122546: use same filename for different exceptions in new repl (#1…

    3d7b1a5
  6. skirpichev
    added a commit that references this issue on Aug 22, 2024

    [3.13] pythongh-122546: use same filename for different exceptions in…

    32bb0f0
  7. cfbolz commented on Aug 22, 2024

    @cfbolz
    cfbolz
    on Aug 22, 2024
    ContributorAuthor
    More actions

    there's another form of the bug, with IndentationError, which still shows <unknown>:

    >>>  b
      File "<unknown>", line 1
        b
    IndentationError: unexpected indent
  8. skirpichev
    added a commit that references this issue on Aug 22, 2024

    pythongh-122546: amends 3d7b1a5 (use issubclass)

    b0d707c
  9. skirpichev commented on Aug 22, 2024

    @skirpichev
    skirpichev
    on Aug 22, 2024
    Member
    More actions

    Yes, we should use less strict type check. Correction: #123233.

  10. pablogsal
    added 3 commits that reference this issue on Aug 22, 2024

    gh-122546: Relax SyntaxError check when raising errors on the new REPL (

    4c3f0cb

    [3.13] gh-122546: use same filename for different exceptions in new r…

    5271f8f

    [3.13] pythongh-122546: Relax SyntaxError check when raising errors o…

    cb10dd5
  11. miss-islington
    added a commit that references this issue on Aug 23, 2024

    pythongh-122546: Relax SyntaxError check when raising errors on the n…

    b9e2f89
  12. pablogsal
    closed this as completedon Aug 23, 2024
  13. pablogsal commented on Aug 23, 2024

    @pablogsal
    pablogsal
    on Aug 23, 2024
    Member
    More actions

    I think we are done. Please reopen if we missed anything. Thanks @skirpichev for the PRs!

  14. pablogsal
    added a commit that references this issue on Aug 23, 2024

    [3.13] gh-122546: Relax SyntaxError check when raising errors on the …

    fda8aec
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.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-replRelated to the interactive shellRelated to the interactive shell

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — 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.