gh-118767: Make bool(NotImplemented) raise TypeError (#118775)

This commit is contained in:
Jelle Zijlstra 2024-05-08 11:12:00 -07:00 committed by GitHub
parent aac6b019fe
commit 3c079a0203
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 14 deletions

View file

@ -2090,13 +2090,9 @@ notimplemented_dealloc(PyObject *notimplemented)
static int
notimplemented_bool(PyObject *v)
{
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"NotImplemented should not be used in a boolean context",
1) < 0)
{
return -1;
}
return 1;
PyErr_SetString(PyExc_TypeError,
"NotImplemented should not be used in a boolean context");
return -1;
}
static PyNumberMethods notimplemented_as_number = {