-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix the itertools.tee leak and race, the contextvars and generator races, _asyncio's InvalidStateError lookup, and _imp's frozen data #8518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2c109b9
9b3095d
68730fd
81f0690
59a8029
fafb317
2a42430
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2745,16 +2745,20 @@ pub(crate) mod _asyncio { | |
| } | ||
| } | ||
|
|
||
| fn get_invalid_state_error_type(vm: &VirtualMachine) -> PyResult<PyTypeRef> { | ||
| let module = vm.import("asyncio.exceptions", 0)?; | ||
| let exc_type = vm | ||
| .get_attribute_opt(module, vm.ctx.intern_str("InvalidStateError"))? | ||
| .ok_or_else(|| vm.new_attribute_error("InvalidStateError not found"))?; | ||
| exc_type | ||
| .downcast() | ||
| .map_err(|_| vm.new_type_error("InvalidStateError is not a type")) | ||
| } | ||
|
|
||
| fn new_invalid_state_error(vm: &VirtualMachine, msg: &str) -> PyBaseExceptionRef { | ||
| match vm.import("asyncio.exceptions", 0) { | ||
| Ok(module) => { | ||
| match vm.get_attribute_opt(module, vm.ctx.intern_str("InvalidStateError")) { | ||
| Ok(Some(exc_type)) => match exc_type.call((msg,), vm) { | ||
| Ok(exc) => exc.downcast().unwrap(), | ||
| Err(_) => vm.new_runtime_error(msg.to_string()), | ||
| }, | ||
| _ => vm.new_runtime_error(msg.to_string()), | ||
| } | ||
| match get_invalid_state_error_type(vm) { | ||
| Ok(invalid_state_error) => { | ||
| vm.new_exception_msg(invalid_state_error, msg.to_string().into()) | ||
| } | ||
| Err(_) => vm.new_runtime_error(msg.to_string()), | ||
| } | ||
|
Comment on lines
+2753
to
2764
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Align exception validation with regression coverage. The runtime code accepts any
📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 21794
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 35722
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 24318
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 18219
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 422
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 329
Read
InvalidStateErrorfromasyncio.exceptions.vm.import("asyncio.exceptions", 0)returns the top-levelasynciomodule because the from-list is empty. The lookup therefore readsasyncio.InvalidStateError. The test changes both aliases, so it does not detect this mismatch. Fetch theexceptionssubmodule before reading the class, and test a change to onlyasyncio.exceptions.InvalidStateError.🤖 Prompt for AI Agents
Source: MCP tools