gh-90872: Use strict unsigned long conversion for DWORD values - #32081
gh-90872: Use strict unsigned long conversion for DWORD values#32081jkloth wants to merge 1 commit into
Conversation
|
Maybe we should start to gradually add test cases for @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
class Win32APITests(unittest.TestCase):
def test_dword_convert_negative(self):
with self.assertRaises(ValueError):
for h in _winapi.CreatePipe(None, -1):
_winapi.CloseHandle(h)
def test_dword_convert_overflow(self):
with self.assertRaises(OverflowError):
for h in _winapi.CreatePipe(None, 1 << 32):
_winapi.CloseHandle(h) |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
The DWORD converter is also used in winreg.c and overlapped.c.
| class DWORD_converter(unsigned_long_converter): | ||
| type = 'DWORD' |
There was a problem hiding this comment.
You can use DWORD(bitwise=True) instead of DWORD in places where you want to keep the old behavior.
Or you can define non-strict by default completely compatible converter:
class DWORD_converter(unsigned_long_converter):
type = 'DWORD'
def converter_init(self, *, bitwise: bool = True) -> None:
super().converter_init(bitwise=bitwise)and use DWORD(bitwise=False) if you need a strict conversion.
|
This PR is stale because it has been open for 30 days with no activity. |
|
But the strict converter also rejects negative values, and this contradicts gh-132629: out of range values for So the question is whether |
The second part of the fix for negative timeouts.
This PR should not 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
-1to denoteINFINITE.https://bugs.python.org/issue46716