https://github.com/python/cpython/commit/2b0cccec390378463c45c7e7cf39fdbbf1f8876c
commit: 2b0cccec390378463c45c7e7cf39fdbbf1f8876c
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2025-12-10T15:54:13Z
summary:

[3.13] gh-139927: Fix test_embed on OpenIndiana (GH-142514) (#142521)

gh-139927: Fix test_embed on OpenIndiana (GH-142514)

Avoid swprintf() function in Programs/_testembed.c since it doesn't
work as expected on OpenIndiana.
(cherry picked from commit c76cfe8d89c5f44b6a012d24c0e14b45eab16b90)

Co-authored-by: Victor Stinner <[email protected]>

files:
M Programs/_testembed.c

diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 6b26b0b3a3f7e4..e57fef2e8898d6 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -1965,15 +1965,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;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to