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

This commit is contained in:
Serhiy Storchaka 2018-12-10 13:50:22 +02:00 committed by GitHub
parent cf247359d5
commit dffccc6b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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 *