bpo-46716: Use strict unsigned long conversion for DWORD values#32081
Open
jkloth wants to merge 1 commit intopython:mainfrom
Open
bpo-46716: Use strict unsigned long conversion for DWORD values#32081jkloth wants to merge 1 commit intopython:mainfrom
jkloth wants to merge 1 commit intopython:mainfrom
Conversation
Contributor
|
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) |
Member
serhiy-storchaka
left a comment
There was a problem hiding this comment.
The DWORD converter is also used in winreg.c and overlapped.c.
Comment on lines
+212
to
+213
| class DWORD_converter(unsigned_long_converter): | ||
| type = 'DWORD' |
Member
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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