bpo-32226: Make __class_getitem__ an automatic class method. (#5098)

This commit is contained in:
Serhiy Storchaka 2018-01-05 00:21:41 +02:00 committed by GitHub
parent 87be28f4a1
commit ce5b0e9db1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 12 deletions

View file

@ -169,11 +169,11 @@ PyObject_GetItem(PyObject *o, PyObject *key)
}
if (PyType_Check(o)) {
PyObject *meth, *result, *stack[2] = {o, key};
PyObject *meth, *result, *stack[1] = {key};
_Py_IDENTIFIER(__class_getitem__);
meth = _PyObject_GetAttrId(o, &PyId___class_getitem__);
if (meth) {
result = _PyObject_FastCall(meth, stack, 2);
result = _PyObject_FastCall(meth, stack, 1);
Py_DECREF(meth);
return result;
}