mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-32226: Make __class_getitem__ an automatic class method. (#5098)
This commit is contained in:
parent
87be28f4a1
commit
ce5b0e9db1
5 changed files with 31 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue