Skip to content

Commit 159404e

Browse files
name-of-okjaclaude
andcommitted
pyexpat: release read lock before is_true in ordered path
Split the `ordered_attributes` `read().clone()` from the `is_true(vm)` call so the `PyRwLockReadGuard` is dropped before running Python code, matching the existing pattern in `invoke_handler`. Assisted-by: Claude:claude-opus-4-8 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a347bcb commit 159404e

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎crates/stdlib/src/pyexpat.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,9 @@ mod _pyexpat {
355355
XmlEvent::StartElement {
356356
name, attributes, ..
357357
} => {
358-
let ordered = self
359-
.ordered_attributes
360-
.read()
361-
.clone()
362-
.is_true(vm)
363-
.unwrap_or(false);
358+
// Clone the flag while holding the read lock, then release the lock
359+
let ordered_attributes = self.ordered_attributes.read().clone();
360+
let ordered = ordered_attributes.is_true(vm).unwrap_or(false);
364361
// Build the container.
365362
let attrs: PyObjectRef = if ordered {
366363
let mut items = Vec::with_capacity(attributes.len() * 2);

0 commit comments

Comments
 (0)