mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-118767: Make bool(NotImplemented) raise TypeError (#118775)
This commit is contained in:
parent
aac6b019fe
commit
3c079a0203
6 changed files with 18 additions and 14 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue