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 — Provide NameError/AttributeError suggestions in traceback.py · Issue #97008 · python/cpython

Provide NameError/AttributeError suggestions in traceback.py #97008

New issue
Copy link
New issue
Copy link
Closed
Closed
Provide NameError/AttributeError suggestions in traceback.py#97008
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@ambv
ambv
opened on Sep 22, 2022
Issue body actions

Python 3.10 added NameError and AttributeError suggestions in raised exceptions, in the form of:

>>> dim
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'dim' is not defined. Did you mean: 'dir'?

This is implemented in Python/suggestions.c and unavailable in the pure Python implementation of traceback formatting in Lib/traceback.py. This makes the output of both different, which is problematic for tooling using traceback.py, as well as for alternative implementations of Python like PyPy and GraalPy.

Let's implement the equivalent of suggestions.c in Lib/traceback.py to bring both in line.

Activity

  1. ambv
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    type-featureA feature request or enhancementA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    and removed
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 22, 2022
  2. ambv commented on Sep 22, 2022

    @ambv
    ambv
    on Sep 22, 2022
    ContributorAuthor
    More actions

    cc @cfbolz

  3. sweeneyde commented on Sep 22, 2022

    @sweeneyde
    sweeneyde
    on Sep 22, 2022
    Member
    More actions

    I'm not sure if exact equivalence with suggestions.c is required, but if not, IIRC there was at one point a call to use difflib's get_close_matches(), which might simplify things.

  4. ambv
    added a commit that references this issue on Sep 22, 2022

    pythongh-97008: Add a Python implementation of AttributeError and Nam…

    ef572ff
  5. cfbolz commented on Sep 22, 2022

    @cfbolz
    cfbolz
    on Sep 22, 2022
    Contributor
    More actions

    @sweeneyde the plan is to start from PyPy's implementation, @ambv and I started working on that today (it's a port of Pablo's original commit, at the time I didn't your later changes hadn't landed).

  6. gpshead commented on Sep 26, 2022

    @gpshead
    gpshead
    on Sep 26, 2022
    Member
    More actions

    cc @Yhg1s

  7. ambv
    added a commit that references this issue on Oct 4, 2022

    gh-97008: Add a Python implementation of AttributeError and NameError…

    bbc7cd6
  8. ambv commented on Oct 4, 2022

    @ambv
    ambv
    on Oct 4, 2022
    ContributorAuthor
    More actions

    Fixed!

  9. ambv
    closed this as completedon Oct 4, 2022
  10. cfbolz commented on Oct 5, 2022

    @cfbolz
    cfbolz
    on Oct 5, 2022
    Contributor
    More actions

    wonderful, thank you @ambv, @pablogsal and @sweeneyde 😊

  11. mpage
    added a commit that references this issue on Oct 11, 2022

    pythongh-97008: Add a Python implementation of AttributeError and Nam…

    c00e5c5
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

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-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.