Skip to content

Avoid crashing on Python 3.14 compiler SyntaxErrors - #1058

Open
ac1982 wants to merge 1 commit into
bpython:mainfrom
ac1982:fix/syntaxerror-attributes
Open

ac1982 wants to merge 1 commit into
bpython:mainfrom
ac1982:fix/syntaxerror-attributes

Conversation

@ac1982

@ac1982 ac1982 commented Oct 13, 2026 •

Copy link
Copy Markdown

On Python 3.14, entering nonlocal a crashes bpython while displaying the resulting SyntaxError: the exception has location attributes but only one item in args.

Update the existing exception's filename when hiding the input-cache identifier, instead of reconstructing it from args[1]. This preserves the original exception, including subclasses, source ranges and notes, while keeping the syntax-error callback and subsequent input working.

Fixes #1051.

  • Full suites on Python 3.14.4 and 3.11.17: each 329 passed, 5 skipped, 3 xfailed, plus 4 passing subtests.
  • Real pseudo-terminal check: base crashes after nonlocal a; the fixed version displays the error, evaluates print(6 * 7) to 42, and exits normally.
  • Build, HTML/man documentation and codespell pass (documentation emits existing warnings). Black passes the changed lines and test file; whole-repository Black requests the same 11 existing files on base and branch. Mypy reports the same two existing formatter.py override errors on both.

Developed and tested with AI assistance.

CI follow-up (2026-10-20): the Python 3.15t failures in TestExecArgs.test_exec_dunder_file and test_exec_nonascii_file reproduce on both upstream base 4a21ac03 and this PR's aaa535d2. In one isolated Python 3.15.0 free-threaded Linux ARM64 environment, using cwcwidth==0.1.12 and curtsies==0.4.3, both trees fail the same two stderr assertions because importing cwcwidth._impl emits the GIL-enabled RuntimeWarning. This matches the warning in the upstream PR run, whose host is x86-64; it is not a claim to have reproduced the entire CI image. The current test_interpreter.py also passes on that free-threaded interpreter: 7 tests and 4 subtests, with the dependency warning still visible. No warning filter or GIL override was added. The existing Black/mypy and coverage statuses remain as reported above; this does not make CI green.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.18%. Comparing base (1a919d3) to head (aaa535d).
⚠️ Report is 48 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1058      +/-   ##
==========================================
- Coverage   76.51%   76.18%   -0.34%     
==========================================
  Files          62       61       -1     
  Lines        8308     8306       -2     
==========================================
- Hits         6357     6328      -29     
- Misses       1951     1978      +27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bpython crashed after executing nonlocal in interactive.

1 participant