]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35452: Make PySys_HasWarnOptions() never raising an exception. (GH-11075)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 10 Dec 2018 12:37:09 +0000 (04:37 -0800)
committerGitHub <noreply@github.com>
Mon, 10 Dec 2018 12:37:09 +0000 (04:37 -0800)
(cherry picked from commit dffccc6b594951fc798973e521da205785823f0f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Python/sysmodule.c

index a0485073817083f5bcda14e1f86200f176dacb0d..efe5b29ef33c8103cfdae0bca9a9c6ffdeb99c1a 100644 (file)
@@ -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 *