python / python/cpython

Inconsistent exception types in code "ᵀrue=1"

Open
#145,675 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core topic-parser type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

It got ValueError in other place when compile without traceback(I think it should be SyntaxError). In IDLE when you run this code it tips SyntaxError (but in compile and exec it can only be caught with ValueError).

Due to that it raised in compile, using SyntaxError to describe it is better.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-145690

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported ValueError with compile and exec for ᵀrue=1, then compare that behavior with IDLE's SyntaxError. The linked PR gh-145690 indicates that work is already underway; done would mean the invalid code consistently raises the intended exception in the affected paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.