From b4c82b7c771f9cd62d06e4d46cf10df52e9c62f6 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 10 Dec 2018 13:50:22 +0200 Subject: [PATCH] bpo-35452: Make PySys_HasWarnOptions() never raising an exception. (GH-11075) (cherry picked from commit dffccc6b594951fc798973e521da205785823f0f) Co-authored-by: Serhiy Storchaka --- Python/sysmodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/sysmodule.c b/Python/sysmodule.c index a0485073817083..efe5b29ef33c81 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 *