mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
bpo-32388: Remove cross-version binary compatibility requirement in tp_flags (GH-4944)
It is now allowed to add new fields at the end of the PyTypeObject struct without having to allocate a dedicated compatibility flag in tp_flags. This will reduce the risk of running out of bits in the 32-bit tp_flags value.
This commit is contained in:
parent
43fdbd2729
commit
ada319bb6d
18 changed files with 52 additions and 51 deletions
|
@ -248,8 +248,8 @@ PyType_Modified(PyTypeObject *type)
|
|||
Invariants:
|
||||
|
||||
- Py_TPFLAGS_VALID_VERSION_TAG is never set if
|
||||
Py_TPFLAGS_HAVE_VERSION_TAG is not set (e.g. on type
|
||||
objects coming from non-recompiled extension modules)
|
||||
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.
|
||||
|
@ -2571,7 +2571,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
|||
|
||||
/* Initialize tp_flags */
|
||||
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE |
|
||||
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_FINALIZE;
|
||||
Py_TPFLAGS_BASETYPE;
|
||||
if (base->tp_flags & Py_TPFLAGS_HAVE_GC)
|
||||
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
|
||||
|
||||
|
@ -5179,10 +5179,7 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
|
|||
COPYSLOT(tp_init);
|
||||
COPYSLOT(tp_alloc);
|
||||
COPYSLOT(tp_is_gc);
|
||||
if ((type->tp_flags & Py_TPFLAGS_HAVE_FINALIZE) &&
|
||||
(base->tp_flags & Py_TPFLAGS_HAVE_FINALIZE)) {
|
||||
COPYSLOT(tp_finalize);
|
||||
}
|
||||
COPYSLOT(tp_finalize);
|
||||
if ((type->tp_flags & Py_TPFLAGS_HAVE_GC) ==
|
||||
(base->tp_flags & Py_TPFLAGS_HAVE_GC)) {
|
||||
/* They agree about gc. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue