-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem() #11112
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 1 commit
6b79d33
b2f44b7
41f2ec3
15046cb
bce5923
fe7a98f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3767,9 +3767,12 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |
| return NULL; | ||
| } | ||
| comma = _PyUnicode_FromId(&comma_id); | ||
| if (comma == NULL) | ||
| if (comma == NULL) { | ||
| Py_DECREF(sorted_methods); | ||
| return NULL; | ||
|
Member
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. Doesn't
Member
Author
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. Good catch! |
||
| } | ||
| joined = PyUnicode_Join(comma, sorted_methods); | ||
| Py_DECREF(sorted_methods); | ||
| if (joined == NULL) | ||
| return NULL; | ||
|
Member
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. Doesn't
Member
Author
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. Good catch! |
||
|
|
||
|
|
||
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.
Doesn't the error need to be returned or cleared?
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.
It is returned below, at line 1713.
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.
The model_module gets reset on line 1705, so the error from the first attempt may remain uncleared or swallowed
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.
Line 1705 is executed only no error was raised at this line.
Error handling in this function (as well as in many other module initialization functions) is pretty poor. Results of
PyModule_AddObject()and derived functions are not checked, and references are leaked in case of error. But this is different issue(s).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.
Then shouldn't line 1704 have
&& !PyErr_Occurred()like line 1694 does?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.
Already added.