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 — dis._try_compile: traceback printed on error in source argument is too wordy · Issue #102114 · python/cpython

dis._try_compile: traceback printed on error in source argument is too wordy #102114

New issue
Copy link
New issue
Copy link
Closed
#102115
Closed
dis._try_compile: traceback printed on error in source argument is too wordy#102114
#102115
Copy link
Labels
3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@chgnrdv
chgnrdv
opened on Feb 21, 2023
Issue body actions

_try_compile function from dis module firstly tries to compile given source string with 'eval' mode and, if exception is occured, catches it and tries again with 'exec' mode. These actions lead to a long chained traceback if given string contains syntax/indentation error, because this string gets refused by compile in both 'eval' and 'exec' modes.
All functions/constructors from dis module that use _try_compile and accept source string as an argument (dis, get_instructions, code_info, show_code, Bytecode) are showing this behavior:

>>> dis.dis(')')
Traceback (most recent call last):
  File "/home/.../cpython/Lib/dis.py", line 67, in _try_compile
    c = compile(source, name, 'eval')
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<dis>", line 1
    )
    ^
SyntaxError: unmatched ')'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.../cpython/Lib/dis.py", line 112, in dis
    _disassemble_str(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
  File "/home/.../cpython/Lib/dis.py", line 593, in _disassemble_str
    _disassemble_recursive(_try_compile(source, '<dis>'), **kwargs)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../cpython/Lib/dis.py", line 69, in _try_compile
    c = compile(source, name, 'exec')
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<dis>", line 1
    )
    ^
SyntaxError: unmatched ')'

Python versions affected: 3.10.8, 3.11.0, current main.

Linked PRs

  • gh-102114: Make dis print more concise tracebacks for syntax errors in str inputs #102115

Activity

  1. chgnrdv
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Feb 21, 2023
  2. chgnrdv
    changed the title [-]dis._try_compile: traceback printed on error in source code is too wordy[/-] [+]dis._try_compile: traceback printed on error in source argument is too wordy[/+] on Feb 21, 2023
  3. arhadthedev
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Feb 21, 2023
  4. iritkatriel
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.12only security fixesonly security fixes
    and removed
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 6, 2023
  5. iritkatriel
    closed this as completedin #102115on Apr 15, 2023
  6. iritkatriel
    added a commit that references this issue on Apr 15, 2023

    gh-102114: Make dis print more concise tracebacks for syntax errors i…

    2b6f5c3
  7. ishaiv28
    added a commit that references this issue on Apr 15, 2023

    Merge pull request #1 from python/main

    d5eab9f
  8. carljm
    added 2 commits that reference this issue on Apr 17, 2023

    Merge branch 'main' into superopt

    5136459

    Merge branch 'superopt' into superopt_spec

    079c65a
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.12only security fixesonly security fixesstdlibStandard 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.