gh-106307: Fix PyMapping_GetOptionalItemString()#108797
gh-106307: Fix PyMapping_GetOptionalItemString()#108797serhiy-storchaka merged 2 commits intopython:mainfrom
Conversation
The resulting pointer was not set to NULL if the creation of a temporary string object was failed. The tests were also missed due to oversight.
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I just propose adding a comment on the new macro.
Does Valgrind or similar tool detect the usage of uninitialized memory?
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
The _testcapi now intializes the variable used in the test:
static PyObject *
mapping_getoptionalitemstring(PyObject *self, PyObject *args)
{
PyObject *obj, *value = UNINITIALIZED_PTR;|
@erlend-aasland: Idea for the devguide: We should suggest to always initialized the |
I have a PR for this, and you already approved it twice 😃 python/devguide#1128 |
|
There are exceptions, like |
|
Exceptions are fine; guidelines are for the general case, not the special case. |
Alright, I should approve it 3 or 4 times 👍👍👍👍 |
The resulting pointer was not set to NULL if the creation of a temporary string object was failed.
The tests were also missed due to oversight.