Skip to content

Commit c76cfe8

Browse files
authored
gh-139927: Fix test_embed on OpenIndiana (#142514)
Avoid swprintf() function in Programs/_testembed.c since it doesn't work as expected on OpenIndiana.
1 parent 2db9573 commit c76cfe8

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Programs/_testembed.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,15 +2063,20 @@ static int check_use_frozen_modules(const char *rawval)
20632063
if (rawval == NULL) {
20642064
wcscpy(optval, L"frozen_modules");
20652065
}
2066-
else if (swprintf(optval, 100,
2067-
#if defined(_MSC_VER)
2068-
L"frozen_modules=%S",
2069-
#else
2070-
L"frozen_modules=%s",
2071-
#endif
2072-
rawval) < 0) {
2073-
error("rawval is too long");
2074-
return -1;
2066+
else {
2067+
wchar_t *val = Py_DecodeLocale(rawval, NULL);
2068+
if (val == NULL) {
2069+
error("unable to decode TESTFROZEN");
2070+
return -1;
2071+
}
2072+
wcscpy(optval, L"frozen_modules=");
2073+
if ((wcslen(optval) + wcslen(val)) >= Py_ARRAY_LENGTH(optval)) {
2074+
error("TESTFROZEN is too long");
2075+
PyMem_RawFree(val);
2076+
return -1;
2077+
}
2078+
wcscat(optval, val);
2079+
PyMem_RawFree(val);
20752080
}
20762081

20772082
PyConfig config;

0 commit comments

Comments
 (0)