GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Implement pyexpat ordered_attributes by name-of-okja · Pull Request #8305 · RustPython/RustPython Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughStart-element attribute handling now checks ChangesXML attribute handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/xml dependencies:
dependent tests: (34 tests)
[x] lib: cpython/Lib/test/libregrtest dependencies:
dependent tests: (no tests depend on regrtest) Legend:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR fixes RustPython’s pyexpat parser to honor the ordered_attributes flag: when enabled, StartElementHandler receives a flat [name, value, ...] list in document order (matching CPython), instead of always receiving a dict. This restores correct behavior for stdlib consumers like xml.etree.ElementTree and xml.dom.minidom that rely on ordered attributes.
Changes:
ordered_attributes handling in pyexpat start-element dispatch (list vs dict).@unittest.expectedFailure markers from test_xml_etree and test_minidom tests that now pass.Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/stdlib/src/pyexpat.rs |
Implements list-vs-dict attribute container based on ordered_attributes. |
Lib/test/test_xml_etree.py |
Removes expected-failure decorators for ElementTree tests now passing. |
Lib/test/test_minidom.py |
Removes expected-failure decorators for minidom tests now passing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let ordered = self | ||
| .ordered_attributes | ||
| .read() | ||
| .clone() | ||
| .is_true(vm) | ||
| .unwrap_or(false); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai is this correct?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@fanninpm, yes—Copilot’s comment is correct.
create_bool_property! normalizes every assignment via is_true() and stores a newly created canonical bool, while the constructor initializes ordered_attributes to False. Therefore, checking identity with vm.ctx.true_value is sufficient:
let ordered = self.ordered_attributes.read().is(&vm.ctx.true_value);
This also avoids the redundant clone and prevents silently treating a hypothetical truthiness error as false.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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 `@crates/stdlib/src/pyexpat.rs`:
- Around line 358-363: In the ordered attribute handling, split the
`self.ordered_attributes.read().clone()` operation from the subsequent
`is_true(vm)` call so the `PyRwLockReadGuard` is dropped before executing Python
code. Update the `ordered` calculation near `is_true(vm)` to use the cloned
value, following the safe pattern in `invoke_handler`.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 62d0e65a-e5d3-4de9-a313-d4135c03d048
Lib/test/test_minidom.py is excluded by !Lib/**Lib/test/test_xml_etree.py is excluded by !Lib/**crates/stdlib/src/pyexpat.rs
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
28ffe9d to
a347bcb
Compare
159404e to
fb1fce0
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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 `@crates/stdlib/src/pyexpat.rs`:
- Line 359: Update the ordered_attributes handling in the surrounding method to
clone the stored attribute reference before evaluating it, ensuring the read
guard is released before truthiness evaluation. Replace the strict
true-singleton identity check with the VM’s normal truthiness conversion so
values such as integer 1 remain truthy while avoiding the deadlock.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: cae68bbd-0a15-4422-ba1a-868a393086e7
Lib/test/test_minidom.py is excluded by !Lib/**Lib/test/test_xml_etree.py is excluded by !Lib/**crates/stdlib/src/pyexpat.rs
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
There's also an unexpected success in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When `ordered_attributes` is set, report attributes to the
StartElementHandler as a flat `[name, value, ...]` list matching
CPython's my_StartElementHandler, instead of always passing a dict.
`xml.etree.ElementTree` and `xml.dom.minidom` (via expatbuilder) both
enable this flag and rely on the flat-list contract, so parsing any
element with attributes previously failed: the dict made `_start` do
integer indexing, raising KeyError which was silently swallowed by the
handler invoker, leaving the tree empty ("missing toplevel element").
Reference (CPython 3.14):
https://github.com/python/cpython/blob/3.14/Modules/pyexpat.c#L439-L443
Remove `@unittest.expectedFailure` from tests that now pass
(23 in test_xml_etree, 15 in test_minidom, 1 in test_regrtest).
Assisted-by: Claude:claude-opus-4-8
Co-Authored-By: Claude Opus 4.8 <[email protected]>
fb1fce0 to
437b912
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It seems related with https://github.com/python/cpython/blob/323c59a5e348347be2ce2b7ea55fcb30bf68b2d3/Modules/pyexpat.c#L430-L497 lines in CPython.
It removed so many @unittest.expectedFailure marks. Thank you!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
great! you break a core blocker
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
When `ordered_attributes` is set, report attributes to the
StartElementHandler as a flat `[name, value, ...]` list matching
CPython's my_StartElementHandler, instead of always passing a dict.
`xml.etree.ElementTree` and `xml.dom.minidom` (via expatbuilder) both
enable this flag and rely on the flat-list contract, so parsing any
element with attributes previously failed: the dict made `_start` do
integer indexing, raising KeyError which was silently swallowed by the
handler invoker, leaving the tree empty ("missing toplevel element").
Reference (CPython 3.14):
https://github.com/python/cpython/blob/3.14/Modules/pyexpat.c#L439-L443
Remove `@unittest.expectedFailure` from tests that now pass
(23 in test_xml_etree, 15 in test_minidom, 1 in test_regrtest).
Assisted-by: Claude:claude-opus-4-8
Co-authored-by: Claude Opus 4.8 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.