diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-05-02 05:29:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-02 05:29:49 (GMT) |
commit | 4d10f703d79b72a9c7f88862c0b4a9abbfb04ee2 (patch) | |
tree | 28304b60468c444e3a8e288fe6fe5741f3b56d0c /Objects | |
parent | ed711290a0d6f40e16acc569dd86cfc4611dbcd3 (diff) | |
download | cpython-4d10f703d79b72a9c7f88862c0b4a9abbfb04ee2.zip cpython-4d10f703d79b72a9c7f88862c0b4a9abbfb04ee2.tar.gz cpython-4d10f703d79b72a9c7f88862c0b4a9abbfb04ee2.tar.bz2 |
gh-92114: Improve error message for types with __class_getitem__ = None (GH-92115)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index cfb0edc..9034737 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -185,11 +185,12 @@ PyObject_GetItem(PyObject *o, PyObject *key) if (_PyObject_LookupAttr(o, &_Py_ID(__class_getitem__), &meth) < 0) { return NULL; } - if (meth) { + if (meth && meth != Py_None) { result = PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } + Py_XDECREF(meth); PyErr_Format(PyExc_TypeError, "type '%.200s' is not subscriptable", ((PyTypeObject *)o)->tp_name); return NULL; |