diff options
author | Mark Shannon <mark@hotpy.org> | 2021-04-30 09:50:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-30 09:50:28 +0100 |
commit | 069e81ab3da46c441335ca762c4333b7bd91861d (patch) | |
tree | 02716907f4513a812cf2c72309cc4e6f133b3ab3 /Objects/typeobject.c | |
parent | 2abbd8f2add5e80b86a965625b9a77ae94a101cd (diff) | |
download | cpython-git-069e81ab3da46c441335ca762c4333b7bd91861d.tar.gz |
bpo-43977: Use tp_flags for collection matching (GH-25723)
* Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes.
* Set relevant flags on collections.abc.Sequence and Mapping.
* Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes.
* Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING.
* Add NEWS
* Remove interpreter-state map_abc and seq_abc fields.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index ac4dc1da44..19d619fada 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5717,10 +5717,15 @@ inherit_special(PyTypeObject *type, PyTypeObject *base) else if (PyType_IsSubtype(base, &PyDict_Type)) { type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS; } - if (PyType_HasFeature(base, _Py_TPFLAGS_MATCH_SELF)) { type->tp_flags |= _Py_TPFLAGS_MATCH_SELF; } + if (PyType_HasFeature(base, Py_TPFLAGS_SEQUENCE)) { + type->tp_flags |= Py_TPFLAGS_SEQUENCE; + } + if (PyType_HasFeature(base, Py_TPFLAGS_MAPPING)) { + type->tp_flags |= Py_TPFLAGS_MAPPING; + } } static int |