Repository navigation
Fix thread UnraisableException object to be None #8326
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
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1296,18 +1296,24 @@ impl VirtualMachine { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let msg_str = if let Some(msg) = msg { | ||||||||||||||||||||||
| format!("{msg}: ") | ||||||||||||||||||||||
| if self.is_none(object) { | ||||||||||||||||||||||
| if let Some(msg) = msg { | ||||||||||||||||||||||
| write_to_stderr(&format!("{msg}:\n"), &stderr, self); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
|
Comment on lines
+1299
to
1303
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Remove the trailing colon when formatting When 🐛 Proposed fix if self.is_none(object) {
if let Some(msg) = msg {
- write_to_stderr(&format!("{msg}:\n"), &stderr, self);
+ write_to_stderr(&format!("{msg}\n"), &stderr, self);
}
} else {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| "Exception ignored in: ".to_owned() | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| write_to_stderr(&msg_str, &stderr, self); | ||||||||||||||||||||||
| let msg_str = if let Some(msg) = msg { | ||||||||||||||||||||||
| format!("{msg}: ") | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| "Exception ignored in: ".to_owned() | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| write_to_stderr(&msg_str, &stderr, self); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let repr_result = object.repr(self); | ||||||||||||||||||||||
| let repr_wtf8 = repr_result | ||||||||||||||||||||||
| .as_ref() | ||||||||||||||||||||||
| .map_or_else(|_| "<object repr failed>".as_ref(), |s| s.as_wtf8()); | ||||||||||||||||||||||
| write_to_stderr(&format!("{repr_wtf8}\n"), &stderr, self); | ||||||||||||||||||||||
| let repr_result = object.repr(self); | ||||||||||||||||||||||
| let repr_wtf8 = repr_result | ||||||||||||||||||||||
| .as_ref() | ||||||||||||||||||||||
| .map_or_else(|_| "<object repr failed>".as_ref(), |s| s.as_wtf8()); | ||||||||||||||||||||||
| write_to_stderr(&format!("{repr_wtf8}\n"), &stderr, self); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Write exception type and message | ||||||||||||||||||||||
| let exc_type_name = e.class().name(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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 | 🟡 Minor | ⚡ Quick win
Handle
reprfailures gracefully to ensure the context message is printed.If
func.as_ref().repr(vm)fails,ok()maps the result toNone, which suppresses the"Exception ignored in thread started by..."context message entirely. CPython prevents this by using a fallback message when the function's representation cannot be retrieved.🐛 Proposed fix to provide a fallback
📝 Committable suggestion
🤖 Prompt for AI Agents