]> granicus.if.org Git - python/commitdiff
bpo-35452: Make PySys_HasWarnOptions() never raising an exception. (GH-11075)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 10 Dec 2018 11:50:22 +0000 (13:50 +0200)
committerGitHub <noreply@github.com>
Mon, 10 Dec 2018 11:50:22 +0000 (13:50 +0200)
Python/sysmodule.c

index e6f1c4e8e9e0c0f41080fc3dc1d58ec63e60ae67..029de2d5ae7fa12b536eb28a999f578f4bd87e22 100644 (file)
@@ -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 *