gh-127572: Fix test_structmembers initialization (GH-127577)

gh-127572: Fix `test_structmembers` initialization.

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 instead of a str).
This commit is contained in:
Sam Gross 2024-12-04 08:58:22 +00:00 committed by GitHub
parent 7f882c88cf
commit 6fc6436749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -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
)

View file

@ -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;