-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-83365: Fix incorrect return value in msvcrt_get_osfhandle_impl
#21322
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
gh-83365: Fix incorrect return value in msvcrt_get_osfhandle_impl
#21322
Conversation
Hi @zooba, could you review this PR if you have time? This PR seems necessary to correct a mistake I made previously. |
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.
Dont we need any tests for this change?
If we had failure tests for all APIs with audit hooks, then I'd insist upon it. But we don't, and this only would've been caught by having broad testing (100+ new tests). It's worth creating an issue for adding that set of tests. They ought to be fairly quick as well (though some will require e.g. making a real network connection, and most will require starting a new Python process for each API), but I think we can take this fix without adding all that. |
The following commit authors need to sign the Contributor License Agreement: |
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 CLA needs to be signed.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
msvcrt_get_osfhandle_impl
msvcrt_get_osfhandle_impl
@@ -209,7 +209,7 @@ msvcrt_get_osfhandle_impl(PyObject *module, int fd) | |||
/*[clinic end generated code: output=aca01dfe24637374 input=5fcfde9b17136aa2]*/ | |||
{ | |||
if (PySys_Audit("msvcrt.get_osfhandle", "(i)", fd) < 0) { | |||
return NULL; | |||
return -1; |
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.
return -1; | |
return (void*)-1; |
Nothing heard from the OP, but also it doesn't seem to be necessary. This function call checks for any error, without looking at the return value. |
As per #18580,
msvcrt_get_osfhandle_impl
should also return -1 instead ofNULL
whenPySys_Audit
fails.https://bugs.python.org/issue39184