]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-139927: Fix test_embed on OpenIndiana (#142514)
authorVictor Stinner <vstinner@python.org>
Wed, 10 Dec 2025 15:31:12 +0000 (16:31 +0100)
committerGitHub <noreply@github.com>
Wed, 10 Dec 2025 15:31:12 +0000 (15:31 +0000)
Avoid swprintf() function in Programs/_testembed.c since it doesn't
work as expected on OpenIndiana.

Programs/_testembed.c

index c6a18249e3ccdd9219dc41c18929b7bb940bbc31..c5e764e426b5f174149c819c80c8daf71009b1d1 100644 (file)
@@ -2063,15 +2063,20 @@ static int check_use_frozen_modules(const char *rawval)
     if (rawval == NULL) {
         wcscpy(optval, L"frozen_modules");
     }
-    else if (swprintf(optval, 100,
-#if defined(_MSC_VER)
-        L"frozen_modules=%S",
-#else
-        L"frozen_modules=%s",
-#endif
-        rawval) < 0) {
-        error("rawval is too long");
-        return -1;
+    else {
+        wchar_t *val = Py_DecodeLocale(rawval, NULL);
+        if (val == NULL) {
+            error("unable to decode TESTFROZEN");
+            return -1;
+        }
+        wcscpy(optval, L"frozen_modules=");
+        if ((wcslen(optval) + wcslen(val)) >= Py_ARRAY_LENGTH(optval)) {
+            error("TESTFROZEN is too long");
+            PyMem_RawFree(val);
+            return -1;
+        }
+        wcscat(optval, val);
+        PyMem_RawFree(val);
     }
 
     PyConfig config;