[Python-checkins] bpo-32030: Make _PySys_AddXOptionWithError() private (GH-10236)
Victor Stinner
webhook-mailer at python.org
Tue Oct 30 09:31:48 EDT 2018
https://github.com/python/cpython/commit/e1b29950bf751381538e3c8ea6a3e0a98d01dbfb
commit: e1b29950bf751381538e3c8ea6a3e0a98d01dbfb
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-10-30T14:31:42+01:00
summary:
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.
files:
M Include/sysmodule.h
M Python/sysmodule.c
diff --git a/Include/sysmodule.h b/Include/sysmodule.h
index 719ecfcf61f2..c5547ff6742e 100644
--- a/Include/sysmodule.h
+++ b/Include/sysmodule.h
@@ -37,11 +37,6 @@ PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);
PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
#endif
-#ifdef Py_BUILD_CORE
-PyAPI_FUNC(int) _PySys_AddXOptionWithError(const wchar_t *s);
-PyAPI_FUNC(int) _PySys_AddWarnOptionWithError(PyObject *option);
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index f88b273e26b1..9579eae4ff5f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1807,7 +1807,7 @@ PySys_ResetWarnOptions(void)
PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL);
}
-int
+static int
_PySys_AddWarnOptionWithError(PyObject *option)
{
PyObject *warnoptions = get_warnoptions();
@@ -1823,7 +1823,12 @@ _PySys_AddWarnOptionWithError(PyObject *option)
void
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
@@ -1877,7 +1882,7 @@ get_xoptions(void)
return xoptions;
}
-int
+static int
_PySys_AddXOptionWithError(const wchar_t *s)
{
PyObject *name = NULL, *value = NULL;
More information about the Python-checkins
mailing list