Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions immutables/_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -3359,13 +3359,6 @@ map_reduce(MapObject *self)
return tup;
}

static PyObject *
map_py_class_getitem(PyObject *type, PyObject *item)
{
Py_INCREF(type);
return type;
}

static PyMethodDef Map_methods[] = {
{"set", (PyCFunction)map_py_set, METH_VARARGS, NULL},
{"get", (PyCFunction)map_py_get, METH_VARARGS, NULL},
Expand All @@ -3379,9 +3372,9 @@ static PyMethodDef Map_methods[] = {
{"__dump__", (PyCFunction)map_py_dump, METH_NOARGS, NULL},
{
"__class_getitem__",
(PyCFunction)map_py_class_getitem,
Py_GenericAlias,
METH_O|METH_CLASS,
NULL
"See PEP 585"
},
{NULL, NULL}
};
Expand Down
11 changes: 11 additions & 0 deletions immutables/pythoncapi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,17 @@ PyFloat_Unpack2(const char *p, int le)
#endif


// bpo-39481 added Py_GenericAlias to Python 3.9.0a6.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be added upstream first. I opened python/pythoncapi-compat#45 for that, though if it turns out to be a bad idea we should instead move the ifdef to _map.c

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're obviously correct. I was sloppy and didn't realize the compat layer was upstream. Thanks for reviewing and opening the PR to try to do this properly.

#if PY_VERSION_HEX < 0x030900A6 && !defined(Py_GenericAlias)
PYCAPI_COMPAT_STATIC_INLINE(PyObject *)
Py_GenericAlias(PyObject *type, PyObject *item)
{
Py_INCREF(type);
return type;
}
#endif


// bpo-46906 added PyFloat_Pack4(), PyFloat_Pack8(), PyFloat_Unpack4() and
// PyFloat_Unpack8() to Python 3.11a7.
// Python 3.11a2 moved _PyFloat_Pack4(), _PyFloat_Pack8(), _PyFloat_Unpack4()
Expand Down