Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
bpo-46716: Use strict unsigned long conversion for DWORD values#32081
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Maybe we should start to gradually add test cases for @unittest.skipUnless(sys.platform=="win32","Win32 specific tests")classWin32APITests(unittest.TestCase):deftest_dword_convert_negative(self):withself.assertRaises(ValueError):forhin_winapi.CreatePipe(None,-1):_winapi.CloseHandle(h)deftest_dword_convert_overflow(self):withself.assertRaises(OverflowError):forhin_winapi.CreatePipe(None,1<<32):_winapi.CloseHandle(h) |
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 DWORD converter is also used inwinreg.c
andoverlapped.c
.
class DWORD_converter(unsigned_long_converter): | ||
type = 'DWORD' |
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.
You can useDWORD(bitwise=True)
instead ofDWORD
in places where you want to keep the old behavior.
Or you can define non-strict by default completely compatible converter:
classDWORD_converter(unsigned_long_converter):type='DWORD'defconverter_init(self,*,bitwise:bool=True)->None:super().converter_init(bitwise=bitwise)
and useDWORD(bitwise=False)
if you need a strict conversion.
Uh oh!
There was an error while loading.Please reload this page.
The second part of the fix for negative timeouts.
This PR shouldnot be backported for the reasons I state here:#32079 (comment)
To further emphasize this, see the additional change required in this PR for use of
-1
to denoteINFINITE
.https://bugs.python.org/issue46716