Accept unparenthesized exception groups in except clauses (PEP 758) - #142
Accept unparenthesized exception groups in except clauses (PEP 758)#142karpovantonme wants to merge 1 commit into
Conversation
PEP 758, accepted for Python 3.14, allows `except A, B:` and `except* A, B:` without parentheses when there is no `as` clause. The parser rejects both today, so a file using the new form fails to parse rather than producing a tree. `GenericList` already collapses a single element to itself and wraps the rest in a tuple, which is the shape CPython produces here, so this is one production per clause. The `as` form is untouched: PEP 758 keeps parentheses required there. python.rs is regenerated with lalrpop 0.20.0, the version that produced the file in tree. The diff is large because the state table renumbers.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe grammar now accepts multiple comma-separated exception types without parentheses in ChangesUnparenthesized exception group parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized parser change adds support for unparenthesized exception groups while preserving existing forms; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Did you check https://github.com/astral-sh/ruff ? RustPython now uses Ruff's parser. |
|
Thank you for contributing. I will merge it as long as it pass test, but it is not related to RustPython anymore as @fanninpm said |
What this is
PEP 758 landed in Python 3.14 and allows
except A, B:andexcept* A, B:without parentheses, as long as there is noasclause. The parser rejects both today, so a file using the new form fails to parse rather than producing a tree.I ran into it scanning Django projects: on one of them 6 files out of 496 failed to parse, all of them on
except ValueError, OSError:.The change
Two productions, one per clause.
GenericListalready collapses a single element to itself and wraps the rest in a tuple, which is the shape CPython produces here:The
asform is untouched. PEP 758 keeps parentheses required there, and so does the grammar after this.No new LALR conflicts: lalrpop generates without complaint.
What I checked
cargo testis green, 183 tests. The new snapshot showsExprTuplefor both clauses, matching CPython.About the diff size
python.rsis regenerated with lalrpop 0.20.0, the version that produced the file in tree, so the change is not mixed with a generator upgrade. It is still ~9.7k lines because the state table renumbers whenever the grammar changes. The hand-written part of this PR is the two productions above, a test and its snapshot.Summary by CodeRabbit
exceptandexcept*clauses.