]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127572: Fix `test_structmembers` initialization (GH-127577)
authorSam Gross <colesbury@gmail.com>
Wed, 4 Dec 2024 08:58:22 +0000 (08:58 +0000)
committerGitHub <noreply@github.com>
Wed, 4 Dec 2024 08:58:22 +0000 (09:58 +0100)
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).

Lib/test/test_capi/test_structmembers.py
Modules/_testcapi/structmember.c

index ae9168fc39243fe8a0f1ab9f9ff72a1382e89a85..f14ad9a9a5f512ed7337ed99debf1d4c0c55d4a8 100644 (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
                )
 
 
index c1861db18c4af271fff3dbda50b6a9e2e472e5a5..ef30a5a9944e3ca854dd93900f8deff5aa94f1f4 100644 (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;