summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2021-07-23 13:21:11 (GMT)
committerGitHub <noreply@github.com>2021-07-23 13:21:11 (GMT)
commita4760cc32d9e5dac7be262e9736eb30502cd7be3 (patch)
tree6f791f7d6c0dacea9cdeccd68e0d405109b4bf03 /Objects
parent7d28a6eb90e2e381e13ba21073c6868fdf6eb058 (diff)
downloadcpython-a4760cc32d9e5dac7be262e9736eb30502cd7be3.zip
cpython-a4760cc32d9e5dac7be262e9736eb30502cd7be3.tar.gz
cpython-a4760cc32d9e5dac7be262e9736eb30502cd7be3.tar.bz2
bpo-42747: Remove Py_TPFLAGS_HAVE_AM_SEND and make Py_TPFLAGS_HAVE_VERSION_TAG no-op (GH-27260)
* Remove code that checks Py_TPFLAGS_HAVE_VERSION_TAG The field is always present in the type struct, as explained in the added comment. * Remove Py_TPFLAGS_HAVE_AM_SEND The flag is not needed, and since it was added in 3.10 it can be removed now.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c4
-rw-r--r--Objects/genobject.c9
-rw-r--r--Objects/typeobject.c23
3 files changed, 6 insertions, 30 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index f14a923..842c367 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2804,9 +2804,7 @@ PyIter_Send(PyObject *iter, PyObject *arg, PyObject **result)
_Py_IDENTIFIER(send);
assert(arg != NULL);
assert(result != NULL);
- if (PyType_HasFeature(Py_TYPE(iter), Py_TPFLAGS_HAVE_AM_SEND)) {
- assert (Py_TYPE(iter)->tp_as_async != NULL);
- assert (Py_TYPE(iter)->tp_as_async->am_send != NULL);
+ if (Py_TYPE(iter)->tp_as_async && Py_TYPE(iter)->tp_as_async->am_send) {
PySendResult res = Py_TYPE(iter)->tp_as_async->am_send(iter, arg, result);
assert(_Py_CheckSlotResult(iter, "am_send", res != PYGEN_ERROR));
return res;
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 27fe15c..8cc965a 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -782,8 +782,7 @@ PyTypeObject PyGen_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- Py_TPFLAGS_HAVE_AM_SEND, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
(traverseproc)gen_traverse, /* tp_traverse */
0, /* tp_clear */
@@ -1029,8 +1028,7 @@ PyTypeObject PyCoro_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- Py_TPFLAGS_HAVE_AM_SEND, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
(traverseproc)gen_traverse, /* tp_traverse */
0, /* tp_clear */
@@ -1415,8 +1413,7 @@ PyTypeObject PyAsyncGen_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- Py_TPFLAGS_HAVE_AM_SEND, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
(traverseproc)async_gen_traverse, /* tp_traverse */
0, /* tp_clear */
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index badd706..42a9978 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -324,10 +324,6 @@ PyType_Modified(PyTypeObject *type)
Invariants:
- - Py_TPFLAGS_VALID_VERSION_TAG is never set if
- Py_TPFLAGS_HAVE_VERSION_TAG is not set (in case of a
- bizarre MRO, see type_mro_modified()).
-
- before Py_TPFLAGS_VALID_VERSION_TAG can be set on a type,
it must first be set on all super types.
@@ -379,9 +375,6 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
PyObject *mro_meth = NULL;
PyObject *type_mro_meth = NULL;
- if (!_PyType_HasFeature(type, Py_TPFLAGS_HAVE_VERSION_TAG))
- return;
-
if (custom) {
mro_meth = lookup_maybe_method(
(PyObject *)type, &PyId_mro, &unbound);
@@ -404,8 +397,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
assert(PyType_Check(b));
cls = (PyTypeObject *)b;
- if (!_PyType_HasFeature(cls, Py_TPFLAGS_HAVE_VERSION_TAG) ||
- !PyType_IsSubtype(type, cls)) {
+ if (!PyType_IsSubtype(type, cls)) {
goto clear;
}
}
@@ -413,8 +405,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
clear:
Py_XDECREF(mro_meth);
Py_XDECREF(type_mro_meth);
- type->tp_flags &= ~(Py_TPFLAGS_HAVE_VERSION_TAG|
- Py_TPFLAGS_VALID_VERSION_TAG);
+ type->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
type->tp_version_tag = 0; /* 0 is not a valid version tag */
}
@@ -431,8 +422,6 @@ assign_version_tag(struct type_cache *cache, PyTypeObject *type)
if (_PyType_HasFeature(type, Py_TPFLAGS_VALID_VERSION_TAG))
return 1;
- if (!_PyType_HasFeature(type, Py_TPFLAGS_HAVE_VERSION_TAG))
- return 0;
if (!_PyType_HasFeature(type, Py_TPFLAGS_READY))
return 0;
@@ -5978,14 +5967,6 @@ type_ready_pre_checks(PyTypeObject *type)
_PyObject_ASSERT((PyObject *)type, type->tp_call != NULL);
}
- /* Consistency check for Py_TPFLAGS_HAVE_AM_SEND - flag requires
- * type->tp_as_async->am_send to be present.
- */
- if (type->tp_flags & Py_TPFLAGS_HAVE_AM_SEND) {
- _PyObject_ASSERT((PyObject *)type, type->tp_as_async != NULL);
- _PyObject_ASSERT((PyObject *)type, type->tp_as_async->am_send != NULL);
- }
-
/* Consistency checks for pattern matching
* Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING are mutually exclusive */
_PyObject_ASSERT((PyObject *)type, (type->tp_flags & COLLECTION_FLAGS) != COLLECTION_FLAGS);