Unverified Kaydet (Commit) e1b29950 authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

bpo-32030: Make _PySys_AddXOptionWithError() private (GH-10236)

Make _PySys_AddXOptionWithError() and _PySys_AddWarnOptionWithError()
functions private again. They are no longer needed to initialize Python:
_PySys_EndInit() is now responsible to add these options instead.

Moreover, PySys_AddWarnOptionUnicode() now clears the exception on
failure if possible.
üst 905f1ace
...@@ -37,11 +37,6 @@ PyAPI_FUNC(PyObject *) PySys_GetXOptions(void); ...@@ -37,11 +37,6 @@ PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);
PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *); PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
#endif #endif
#ifdef Py_BUILD_CORE
PyAPI_FUNC(int) _PySys_AddXOptionWithError(const wchar_t *s);
PyAPI_FUNC(int) _PySys_AddWarnOptionWithError(PyObject *option);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -1807,7 +1807,7 @@ PySys_ResetWarnOptions(void) ...@@ -1807,7 +1807,7 @@ PySys_ResetWarnOptions(void)
PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL);
} }
int static int
_PySys_AddWarnOptionWithError(PyObject *option) _PySys_AddWarnOptionWithError(PyObject *option)
{ {
PyObject *warnoptions = get_warnoptions(); PyObject *warnoptions = get_warnoptions();
...@@ -1823,7 +1823,12 @@ _PySys_AddWarnOptionWithError(PyObject *option) ...@@ -1823,7 +1823,12 @@ _PySys_AddWarnOptionWithError(PyObject *option)
void void
PySys_AddWarnOptionUnicode(PyObject *option) PySys_AddWarnOptionUnicode(PyObject *option)
{ {
(void)_PySys_AddWarnOptionWithError(option); if (_PySys_AddWarnOptionWithError(option) < 0) {
/* No return value, therefore clear error state if possible */
if (_PyThreadState_UncheckedGet()) {
PyErr_Clear();
}
}
} }
void void
...@@ -1877,7 +1882,7 @@ get_xoptions(void) ...@@ -1877,7 +1882,7 @@ get_xoptions(void)
return xoptions; return xoptions;
} }
int static int
_PySys_AddXOptionWithError(const wchar_t *s) _PySys_AddXOptionWithError(const wchar_t *s)
{ {
PyObject *name = NULL, *value = NULL; PyObject *name = NULL, *value = NULL;
......
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