diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-05-08 05:25:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-08 05:25:50 (GMT) |
commit | 02fa0ea9c1073e4476c9bde3d7112f5dd964aa57 (patch) | |
tree | 77db423fdfaede444989d4f36cd7978f5b31652f /Objects | |
parent | db9163ceef31ba00ccb23226917f9c8e9142a0b8 (diff) | |
download | cpython-02fa0ea9c1073e4476c9bde3d7112f5dd964aa57.zip cpython-02fa0ea9c1073e4476c9bde3d7112f5dd964aa57.tar.gz cpython-02fa0ea9c1073e4476c9bde3d7112f5dd964aa57.tar.bz2 |
bpo-40273: Reversible mappingproxy (FH-19513)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index c9754a1..c29cf7a 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1118,6 +1118,13 @@ mappingproxy_copy(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) return _PyObject_CallMethodIdNoArgs(pp->mapping, &PyId_copy); } +static PyObject * +mappingproxy_reversed(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) +{ + _Py_IDENTIFIER(__reversed__); + return _PyObject_CallMethodIdNoArgs(pp->mapping, &PyId___reversed__); +} + /* WARNING: mappingproxy methods must not give access to the underlying mapping */ @@ -1135,6 +1142,8 @@ static PyMethodDef mappingproxy_methods[] = { PyDoc_STR("D.copy() -> a shallow copy of D")}, {"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, + {"__reversed__", (PyCFunction)mappingproxy_reversed, METH_NOARGS, + PyDoc_STR("D.__reversed__() -> reverse iterator")}, {0} }; |