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 *