-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-44980: fix test_constructor to return None value #27898
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
bpo-44980: fix test_constructor to return None value #27898
Conversation
It might also be good to test contents of the null tuple? |
You could but since we weren't looking at those before, this is new behavior that isn't necessarily the point of this PR. |
🤖 New build scheduled with the buildbot fleet by @ambv for commit 0d986418e50ab4f029845fa115976a5837a0a450 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
"test-with-buildbots" will test for refleaks for us. |
Modules/_testcapimodule.c
Outdated
Py_XDECREF(tuple); | ||
Py_RETURN_NONE; |
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.
If tuple
is NULL, the result should be NULL.
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.
I should wait for buildbots to finish to push this change right?
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.
No, you do not need to wait for buildbots.
Refleaks bot failure seems unrelated: 2:10:42 load avg: 5.18 [ 58/428/1] test_mailbox failed (1 failure) (2 hour 31 sec) -- running: test_gzip (1 hour 44 min), test_cmd_line (1 hour 39 min), test_argparse (1 hour 39 min) |
Modules/_testcapimodule.c
Outdated
@@ -2383,9 +2383,13 @@ test_null_strings(PyObject *self, PyObject *Py_UNUSED(ignored)) | |||
{ | |||
PyObject *o1 = PyObject_Str(NULL), *o2 = PyObject_Str(NULL); | |||
PyObject *tuple = PyTuple_Pack(2, o1, o2); | |||
if (tuple == NULL) { | |||
return NULL; |
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.
o1
and o2
may be leaked here.
Modules/_testcapimodule.c
Outdated
Py_XDECREF(tuple); | ||
Py_RETURN_NONE; |
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.
No, you do not need to wait for buildbots.
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.
Looking at the history of test_null_strings I decided that it should be completely rewritten. #27904.
Modules/_testcapimodule.c
Outdated
@@ -2385,7 +2385,11 @@ test_null_strings(PyObject *self, PyObject *Py_UNUSED(ignored)) | |||
PyObject *tuple = PyTuple_Pack(2, o1, o2); | |||
Py_XDECREF(o1); | |||
Py_XDECREF(o2); | |||
return tuple; | |||
Py_XDECREF(tuple); | |||
if (tuple == NULL) { |
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.
BTW, comparing a pointer to freed memory with NULL is undefined behavior. Py_DECREF(tuple)
should be after if (tuple == NULL)
.
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.
Looks like I've forgotten what I knew of C; thanks for reviewing and catching this!
74de888
to
87c0f83
Compare
I rebased on |
GH-27913 is a backport of this pull request to the 3.10 branch. |
(cherry picked from commit 27b761a) Co-authored-by: andrei kulakov <[email protected]>
(cherry picked from commit 27b761a) Co-authored-by: andrei kulakov <[email protected]>
GH-27914 is a backport of this pull request to the 3.9 branch. |
@ambv thanks, I'll make sure to do that next time! |
…7914) (cherry picked from commit 27b761a) Co-authored-by: andrei kulakov <[email protected]>
(cherry picked from commit 27b761a) Co-authored-by: andrei kulakov <[email protected]>
Update test_constructor() to conform to deprecation in #27748
https://bugs.python.org/issue44980