[Python-checkins] gh-76961: Fix buildbot failures in test_pep3118 (#101587)

mdickinson webhook-mailer at python.org
Mon Feb 6 07:25:38 EST 2023


https://github.com/python/cpython/commit/46416b9004b687856eaa73e5d48520cd768bbf82
commit: 46416b9004b687856eaa73e5d48520cd768bbf82
branch: main
author: Mark Dickinson <dickinsm at gmail.com>
committer: mdickinson <dickinsm at gmail.com>
date: 2023-02-06T12:25:31Z
summary:

gh-76961: Fix buildbot failures in test_pep3118 (#101587)

This PR fixes the buildbot failures introduced by the merge of #5561, by restricting the relevant tests to something that should work on both 32-bit and 64-bit platforms. It also silences some compiler warnings introduced in that PR.

files:
M Lib/test/test_ctypes/test_pep3118.py
M Modules/_ctypes/stgdict.c

diff --git a/Lib/test/test_ctypes/test_pep3118.py b/Lib/test/test_ctypes/test_pep3118.py
index 74fdf29fc9ad..c8a70e3e3356 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_uint)]
 
 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_uint), ("y", c_byte)]
 
 class PackedPointEndPad(Structure):
     _pack_ = 2
@@ -199,14 +199,14 @@ class Complete(Structure):
 
     ## structures and unions
 
-    (Point2,                    "T{<l:x:<l:y:}".replace('l', s_long),  (),  Point2),
-    (Point,                     "T{<l:x:<l:y:}".replace('l', s_long),  (),  Point),
-    (PackedPoint,               "T{<l:x:<l:y:}".replace('l', s_long),  (),  PackedPoint),
-    (PointMidPad,               "T{<b:x:7x<Q:y:}",                     (),  PointMidPad),
-    (PackedPointMidPad,         "T{<b:x:x<Q:y:}",                      (),  PackedPointMidPad),
-    (PointEndPad,               "T{<Q:x:<b:y:7x}",                     (),  PointEndPad),
-    (PackedPointEndPad,         "T{<Q:x:<b:y:x}",                      (),  PackedPointEndPad),
-    (EmptyStruct,               "T{}",                                 (),  EmptyStruct),
+    (Point2,                    "T{<l:x:<l:y:}".replace('l', s_long),   (),  Point2),
+    (Point,                     "T{<l:x:<l:y:}".replace('l', s_long),   (),  Point),
+    (PackedPoint,               "T{<l:x:<l:y:}".replace('l', s_long),   (),  PackedPoint),
+    (PointMidPad,               "T{<b:x:3x<I:y:}".replace('I', s_uint), (),  PointMidPad),
+    (PackedPointMidPad,         "T{<b:x:x<Q:y:}",                       (),  PackedPointMidPad),
+    (PointEndPad,               "T{<I:x:<b:y:3x}".replace('I', s_uint), (),  PointEndPad),
+    (PackedPointEndPad,         "T{<Q:x:<b:y:x}",                       (),  PackedPointEndPad),
+    (EmptyStruct,               "T{}",                                  (),  EmptyStruct),
     # the pep doesn't support unions
     (aUnion,                    "B",                                   (),  aUnion),
     # structure with sub-arrays
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index dac772e30731..83a52757d609 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 *
@@ -355,8 +355,8 @@ _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);
-    assert(0 <= ret && ret < sizeof(buf));
+    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);
 }
 



More information about the Python-checkins mailing list