mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-60580: Fix a wrong type of ctypes.wintypes.BYTE
(#97579)
Created from a patch file attached to an issue, by Anatoly Techtonik.
This commit is contained in:
parent
f2ac9510a5
commit
409f5337a3
3 changed files with 23 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
# The most useful windows datatypes
|
||||
import ctypes
|
||||
|
||||
BYTE = ctypes.c_byte
|
||||
BYTE = ctypes.c_ubyte
|
||||
WORD = ctypes.c_ushort
|
||||
DWORD = ctypes.c_ulong
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# See <https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types>
|
||||
# for reference.
|
||||
|
||||
import unittest
|
||||
|
||||
# also work on POSIX
|
||||
|
@ -38,6 +41,22 @@ class WinTypesTest(unittest.TestCase):
|
|||
vb.value = []
|
||||
self.assertIs(vb.value, False)
|
||||
|
||||
def assertIsSigned(self, ctype):
|
||||
self.assertLess(ctype(-1).value, 0)
|
||||
|
||||
def assertIsUnsigned(self, ctype):
|
||||
self.assertGreater(ctype(-1).value, 0)
|
||||
|
||||
def test_signedness(self):
|
||||
for ctype in (wintypes.BYTE, wintypes.WORD, wintypes.DWORD,
|
||||
wintypes.BOOLEAN, wintypes.UINT, wintypes.ULONG):
|
||||
with self.subTest(ctype=ctype):
|
||||
self.assertIsUnsigned(ctype)
|
||||
|
||||
for ctype in (wintypes.BOOL, wintypes.INT, wintypes.LONG):
|
||||
with self.subTest(ctype=ctype):
|
||||
self.assertIsSigned(ctype)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue