From 3586c0903c0e19675f5cef3d94c8b0158cb0ed09 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 5 Feb 2023 19:23:32 +0000 Subject: [PATCH 1/5] Possible fix for buildbot failures in test_pep3118 --- Lib/test/test_ctypes/test_pep3118.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_ctypes/test_pep3118.py b/Lib/test/test_ctypes/test_pep3118.py index 74fdf29fc9ad05..25bf7d299a0888 100644 --- a/Lib/test/test_ctypes/test_pep3118.py +++ b/Lib/test/test_ctypes/test_pep3118.py @@ -87,14 +87,14 @@ class PackedPoint(Structure): _fields_ = [("x", c_long), ("y", c_long)] class PointMidPad(Structure): - _fields_ = [("x", c_byte), ("y", c_uint64)] + _fields_ = [("x", c_byte), ("y", c_uint32)] class PackedPointMidPad(Structure): _pack_ = 2 _fields_ = [("x", c_byte), ("y", c_uint64)] class PointEndPad(Structure): - _fields_ = [("x", c_uint64), ("y", c_byte)] + _fields_ = [("x", c_uint32), ("y", c_byte)] class PackedPointEndPad(Structure): _pack_ = 2 @@ -202,9 +202,9 @@ class Complete(Structure): (Point2, "T{ Date: Sun, 5 Feb 2023 19:51:16 +0000 Subject: [PATCH 2/5] Use uint instead of uint32 --- Lib/test/test_ctypes/test_pep3118.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ctypes/test_pep3118.py b/Lib/test/test_ctypes/test_pep3118.py index 25bf7d299a0888..6310f9c1a1e0ac 100644 --- a/Lib/test/test_ctypes/test_pep3118.py +++ b/Lib/test/test_ctypes/test_pep3118.py @@ -87,14 +87,14 @@ class PackedPoint(Structure): _fields_ = [("x", c_long), ("y", c_long)] class PointMidPad(Structure): - _fields_ = [("x", c_byte), ("y", c_uint32)] + _fields_ = [("x", c_byte), ("y", c_uint)] class PackedPointMidPad(Structure): _pack_ = 2 _fields_ = [("x", c_byte), ("y", c_uint64)] class PointEndPad(Structure): - _fields_ = [("x", c_uint32), ("y", c_byte)] + _fields_ = [("x", c_uint), ("y", c_byte)] class PackedPointEndPad(Structure): _pack_ = 2 From 1222418575311373ea9d721b202f601998f111e4 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 5 Feb 2023 19:57:29 +0000 Subject: [PATCH 3/5] Suppress warnings from -Wsign-compare --- Modules/_ctypes/stgdict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index dac772e3073112..41d50512819636 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -339,7 +339,7 @@ MakeAnonFields(PyObject *type) /* Allocate a memory block for a pep3118 format string, copy prefix (if - non-null) into it and append `{padding}x` to the end. + non-null) into it and append `{padding}x` to the end. Returns NULL on failure, with the error indicator set. */ char * @@ -356,7 +356,7 @@ _ctypes_alloc_format_padding(const char *prefix, Py_ssize_t padding) } int ret = PyOS_snprintf(buf, sizeof(buf), "%zdx", padding); - assert(0 <= ret && ret < sizeof(buf)); + assert(0 <= ret && ret < (Py_ssize_t)sizeof(buf)); return _ctypes_alloc_format_string(prefix, buf); } From f273e74c3bf2e74e2ddaf4de4149d02ec851ef9b Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 5 Feb 2023 20:03:16 +0000 Subject: [PATCH 4/5] Silence Wunused-variable via the time-honoured solution of casting to void --- Modules/_ctypes/stgdict.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 41d50512819636..83a52757d60979 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -355,7 +355,7 @@ _ctypes_alloc_format_padding(const char *prefix, Py_ssize_t padding) return _ctypes_alloc_format_string(prefix, "x"); } - int ret = PyOS_snprintf(buf, sizeof(buf), "%zdx", padding); + int ret = PyOS_snprintf(buf, sizeof(buf), "%zdx", padding); (void)ret; assert(0 <= ret && ret < (Py_ssize_t)sizeof(buf)); return _ctypes_alloc_format_string(prefix, buf); } From 59144e7130066ce37851692ddeedfb652a3804a6 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 5 Feb 2023 20:34:07 +0000 Subject: [PATCH 5/5] One more try: replace 'I' with s_uint --- Lib/test/test_ctypes/test_pep3118.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_ctypes/test_pep3118.py b/Lib/test/test_ctypes/test_pep3118.py index 6310f9c1a1e0ac..c8a70e3e335693 100644 --- a/Lib/test/test_ctypes/test_pep3118.py +++ b/Lib/test/test_ctypes/test_pep3118.py @@ -199,14 +199,14 @@ class Complete(Structure): ## structures and unions - (Point2, "T{