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-28474: Handle unsigned long win32 error codes #27959
base: main
Are you sure you want to change the base?
Conversation
if (winerrcode == -1 && PyErr_Occurred()) | ||
return -1; | ||
|
||
if(winerrcode < LONG_MIN || winerrcode > ULONG_MAX) { |
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(winerrcode < LONG_MIN || winerrcode > ULONG_MAX) { | |
if((int)winerrcode != winerrcode) { |
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.
From my understanding, this change would break error codes greater than LONG_MAX
, which are still valid and this PR is adding support for. For example, this change raises an exception for a valid DWORD error code.
>>> OSError(0, '', None, 0x80000005)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: error code 2147483653 too big for int
This PR is stale because it has been open for 30 days with no activity. |
Co-authored-by: Steve Dower <[email protected]>
@zooba I've rebased from upstream/main and have addressed all feedback items, except one that I think it out of scope. Let me know if you need anything else from me. |
bpo-28474: Handle unsigned long win32 error codes
Windows Error Codes are
DWORD
values. This PR ensures that error codes larger thanLONG_MAX
are handled. Previously, an overflow exception was raised for large, but valid, win32 error codes, such asE_POINTER 0x80000005
.https://bugs.python.org/issue28474