Cleanup: update old comment for why we can't use PySys_SetArgv

This commit is contained in:
Campbell Barton 2020-10-28 13:48:02 +11:00
parent 58fc155976
commit a0f2866a8e
1 changed files with 6 additions and 7 deletions

View File

@ -349,17 +349,16 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
/* Initialize Python (also acquires lock). */
Py_Initialize();
// PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
/* sigh, why do python guys not have a (char **) version anymore? */
/* We could convert to #wchar_t then pass to #PySys_SetArgv (or use #PyConfig in Python 3.8+).
* However this risks introducing subtle changes in encoding that are hard to track down.
*
* So rely on #PyC_UnicodeFromByte since it's a tried & true way of getting paths
* that include non `utf-8` compatible characters, see: T20021. */
{
int i;
PyObject *py_argv = PyList_New(argc);
for (i = 0; i < argc; i++) {
/* should fix bug T20021 - utf path name problems, by replacing
* PyUnicode_FromString, with this one */
for (int i = 0; i < argc; i++) {
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
}
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
}