[Python-checkins] bpo-35452: Make PySys_HasWarnOptions() never raising an exception. (GH-11075)

Serhiy Storchaka webhook-mailer at python.org
Mon Dec 10 06:50:25 EST 2018


https://github.com/python/cpython/commit/dffccc6b594951fc798973e521da205785823f0f
commit: dffccc6b594951fc798973e521da205785823f0f
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-12-10T13:50:22+02:00
summary:

bpo-35452: Make PySys_HasWarnOptions() never raising an exception. (GH-11075)

files:
M Python/sysmodule.c

diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index e6f1c4e8e9e0..029de2d5ae7f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1845,7 +1845,8 @@ int
 PySys_HasWarnOptions(void)
 {
     PyObject *warnoptions = _PySys_GetObjectId(&PyId_warnoptions);
-    return (warnoptions != NULL && (PyList_Size(warnoptions) > 0)) ? 1 : 0;
+    return (warnoptions != NULL && PyList_Check(warnoptions)
+            && PyList_GET_SIZE(warnoptions) > 0);
 }
 
 static PyObject *



More information about the Python-checkins mailing list