Commit 36242fd8 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-36763: Add PyConfig_SetWideStringList() (GH-14444)

parent e21b45a8
...@@ -25,6 +25,7 @@ Functions: ...@@ -25,6 +25,7 @@ Functions:
* :c:func:`PyConfig_SetBytesArgv` * :c:func:`PyConfig_SetBytesArgv`
* :c:func:`PyConfig_SetBytesString` * :c:func:`PyConfig_SetBytesString`
* :c:func:`PyConfig_SetString` * :c:func:`PyConfig_SetString`
* :c:func:`PyConfig_SetWideStringList`
* :c:func:`PyPreConfig_InitIsolatedConfig` * :c:func:`PyPreConfig_InitIsolatedConfig`
* :c:func:`PyPreConfig_InitPythonConfig` * :c:func:`PyPreConfig_InitPythonConfig`
* :c:func:`PyStatus_Error` * :c:func:`PyStatus_Error`
...@@ -368,6 +369,12 @@ PyConfig ...@@ -368,6 +369,12 @@ PyConfig
Preinitialize Python if needed. Preinitialize Python if needed.
.. c:function:: PyStatus PyConfig_SetWideStringList(PyConfig *config, PyWideStringList *list, Py_ssize_t length, wchar_t **items)
Set the list of wide strings *list* to *length* and *items*.
Preinitialize Python if needed.
.. c:function:: PyStatus PyConfig_Read(PyConfig *config) .. c:function:: PyStatus PyConfig_Read(PyConfig *config)
Read all Python configuration. Read all Python configuration.
......
...@@ -422,6 +422,9 @@ PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv( ...@@ -422,6 +422,9 @@ PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv(
PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config, PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config,
Py_ssize_t argc, Py_ssize_t argc,
wchar_t * const *argv); wchar_t * const *argv);
PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
PyWideStringList *list,
Py_ssize_t length, wchar_t **items);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
Add :func:`PyConfig_SetWideStringList` function.
...@@ -732,7 +732,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2) ...@@ -732,7 +732,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
} while (0) } while (0)
#define COPY_WSTRLIST(LIST) \ #define COPY_WSTRLIST(LIST) \
do { \ do { \
if (_PyWideStringList_Copy(&config->LIST, &config2->LIST) < 0 ) { \ if (_PyWideStringList_Copy(&config->LIST, &config2->LIST) < 0) { \
return _PyStatus_NO_MEMORY(); \ return _PyStatus_NO_MEMORY(); \
} \ } \
} while (0) } while (0)
...@@ -2324,6 +2324,23 @@ PyConfig_SetArgv(PyConfig *config, Py_ssize_t argc, wchar_t * const *argv) ...@@ -2324,6 +2324,23 @@ PyConfig_SetArgv(PyConfig *config, Py_ssize_t argc, wchar_t * const *argv)
} }
PyStatus
PyConfig_SetWideStringList(PyConfig *config, PyWideStringList *list,
Py_ssize_t length, wchar_t **items)
{
PyStatus status = _Py_PreInitializeFromConfig(config, NULL);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
PyWideStringList list2 = {.length = length, .items = items};
if (_PyWideStringList_Copy(list, &list2) < 0) {
return _PyStatus_NO_MEMORY();
}
return _PyStatus_OK();
}
/* Read the configuration into PyConfig from: /* Read the configuration into PyConfig from:
* Command line arguments * Command line arguments
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment