summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-10-30 13:31:42 (GMT)
committerGitHub <noreply@github.com>2018-10-30 13:31:42 (GMT)
commite1b29950bf751381538e3c8ea6a3e0a98d01dbfb (patch)
treef52d54f2efda4afd9a2fff1eb4330d7b0999ad8b /Python/sysmodule.c
parent905f1ace5f7424e314ca7bed997868a2a3044839 (diff)
downloadcpython-e1b29950bf751381538e3c8ea6a3e0a98d01dbfb.zip
cpython-e1b29950bf751381538e3c8ea6a3e0a98d01dbfb.tar.gz
cpython-e1b29950bf751381538e3c8ea6a3e0a98d01dbfb.tar.bz2
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.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index f88b273..9579eae 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;