Skip to content

Commit

Permalink
pythongh-127572: Fix test_structmembers initialization.
Browse files Browse the repository at this point in the history
The 'C' format code expects an `int` as a destination (not a `char`).
This led to test failures on big-endian platforms like s390x. Use the
'c' format code, which expects a `char` as the destination (but requires
a Python byte objects intead of a str).
  • Loading branch information
colesbury committed Dec 3, 2024
1 parent 0cb5222 commit 7902c35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_structmembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _make_test_object(cls):
"hi", # T_STRING_INPLACE
12, # T_LONGLONG
13, # T_ULONGLONG
"c", # T_CHAR
b"c", # T_CHAR
)


Expand Down
2 changes: 1 addition & 1 deletion Modules/_testcapi/structmember.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
"T_FLOAT", "T_DOUBLE", "T_STRING_INPLACE",
"T_LONGLONG", "T_ULONGLONG", "T_CHAR",
NULL};
static const char fmt[] = "|bbBhHiIlknfds#LKC";
static const char fmt[] = "|bbBhHiIlknfds#LKc";
test_structmembers *ob;
const char *s = NULL;
Py_ssize_t string_len = 0;
Expand Down

0 comments on commit 7902c35

Please sign in to comment.