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

Miss Islington (bot) webhook-mailer at python.org
Mon Dec 10 07:37:12 EST 2018


https://github.com/python/cpython/commit/ea773eb1f9e79e9f558ca1fe8909cf6ac1c00371
commit: ea773eb1f9e79e9f558ca1fe8909cf6ac1c00371
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-12-10T04:37:09-08:00
summary:

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

(cherry picked from commit dffccc6b594951fc798973e521da205785823f0f)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>

files:
M Python/sysmodule.c

diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index a04850738170..efe5b29ef33c 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1823,7 +1823,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