ast: fix identifier interning - #8361
Conversation
Ensure parsed name and function identifier fields use interned strings, matching CPython behavior. Assisted-by: Codex:gpt-5.6-sol
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAST expression and function-definition name conversion now uses AST-aware serialization, with regression tests covering interned identifier identity and ChangesAST identifier serialization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/ast.py dependencies:
dependent tests: (149 tests)
Legend:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@extra_tests/snippets/stdlib_ast.py`:
- Line 43: Move the copy import from its current position after executable
top-level statements into the module’s existing top-level import block,
preserving the surrounding import ordering and leaving executable code
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: e7382c2a-71e2-4390-b543-ea7a719d828a
⛔ Files ignored due to path filters (1)
Lib/test/test_ast/test_ast.pyis excluded by!Lib/**
📒 Files selected for processing (3)
crates/vm/src/stdlib/_ast/expression.rscrates/vm/src/stdlib/_ast/statement.rsextra_tests/snippets/stdlib_ast.py
Summary
Ensure that identifier fields produced while converting parsed AST nodes use
interned Python strings, matching CPython behavior. In particular, this fixes
Name.idand function definitionnamefields.This restores identity-sensitive behavior used by
copy.replace()and removesthe three
test_astexpected-failure markers that now pass. Add regressioncoverage for expression, synchronous-function, and async-function identifiers.
Testing
AI assistance: Codex:gpt-5.6-sol
Summary by CodeRabbit
Bug Fixes
id/namevalues match the expected representation and preserve correct identity semantics.copy/replacebehavior to retain the original identifier and context while dropping unrelated dynamically added attributes.Tests