Skip to content

Commit 46416b9

Browse files
authored
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.
1 parent 9ef7e75 commit 46416b9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Lib/test/test_ctypes/test_pep3118.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ class PackedPoint(Structure):
8787
_fields_ = [("x", c_long), ("y", c_long)]
8888

8989
class PointMidPad(Structure):
90-
_fields_ = [("x", c_byte), ("y", c_uint64)]
90+
_fields_ = [("x", c_byte), ("y", c_uint)]
9191

9292
class PackedPointMidPad(Structure):
9393
_pack_ = 2
9494
_fields_ = [("x", c_byte), ("y", c_uint64)]
9595

9696
class PointEndPad(Structure):
97-
_fields_ = [("x", c_uint64), ("y", c_byte)]
97+
_fields_ = [("x", c_uint), ("y", c_byte)]
9898

9999
class PackedPointEndPad(Structure):
100100
_pack_ = 2
@@ -199,14 +199,14 @@ class Complete(Structure):
199199

200200
## structures and unions
201201

202-
(Point2, "T{<l:x:<l:y:}".replace('l', s_long), (), Point2),
203-
(Point, "T{<l:x:<l:y:}".replace('l', s_long), (), Point),
204-
(PackedPoint, "T{<l:x:<l:y:}".replace('l', s_long), (), PackedPoint),
205-
(PointMidPad, "T{<b:x:7x<Q:y:}", (), PointMidPad),
206-
(PackedPointMidPad, "T{<b:x:x<Q:y:}", (), PackedPointMidPad),
207-
(PointEndPad, "T{<Q:x:<b:y:7x}", (), PointEndPad),
208-
(PackedPointEndPad, "T{<Q:x:<b:y:x}", (), PackedPointEndPad),
209-
(EmptyStruct, "T{}", (), EmptyStruct),
202+
(Point2, "T{<l:x:<l:y:}".replace('l', s_long), (), Point2),
203+
(Point, "T{<l:x:<l:y:}".replace('l', s_long), (), Point),
204+
(PackedPoint, "T{<l:x:<l:y:}".replace('l', s_long), (), PackedPoint),
205+
(PointMidPad, "T{<b:x:3x<I:y:}".replace('I', s_uint), (), PointMidPad),
206+
(PackedPointMidPad, "T{<b:x:x<Q:y:}", (), PackedPointMidPad),
207+
(PointEndPad, "T{<I:x:<b:y:3x}".replace('I', s_uint), (), PointEndPad),
208+
(PackedPointEndPad, "T{<Q:x:<b:y:x}", (), PackedPointEndPad),
209+
(EmptyStruct, "T{}", (), EmptyStruct),
210210
# the pep doesn't support unions
211211
(aUnion, "B", (), aUnion),
212212
# structure with sub-arrays

Modules/_ctypes/stgdict.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ MakeAnonFields(PyObject *type)
339339

340340
/*
341341
Allocate a memory block for a pep3118 format string, copy prefix (if
342-
non-null) into it and append `{padding}x` to the end.
342+
non-null) into it and append `{padding}x` to the end.
343343
Returns NULL on failure, with the error indicator set.
344344
*/
345345
char *
@@ -355,8 +355,8 @@ _ctypes_alloc_format_padding(const char *prefix, Py_ssize_t padding)
355355
return _ctypes_alloc_format_string(prefix, "x");
356356
}
357357

358-
int ret = PyOS_snprintf(buf, sizeof(buf), "%zdx", padding);
359-
assert(0 <= ret && ret < sizeof(buf));
358+
int ret = PyOS_snprintf(buf, sizeof(buf), "%zdx", padding); (void)ret;
359+
assert(0 <= ret && ret < (Py_ssize_t)sizeof(buf));
360360
return _ctypes_alloc_format_string(prefix, buf);
361361
}
362362

0 commit comments

Comments
 (0)