mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +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
|
@ -263,17 +263,14 @@ PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
|
|||
#define Py_PRINT_RAW 1 /* No string quotes etc. */
|
||||
|
||||
/*
|
||||
`Type flags (tp_flags)
|
||||
Type flags (tp_flags)
|
||||
|
||||
These flags are used to extend the type structure in a backwards-compatible
|
||||
fashion. Extensions can use the flags to indicate (and test) when a given
|
||||
type structure contains a new feature. The Python core will use these when
|
||||
introducing new functionality between major revisions (to avoid mid-version
|
||||
changes in the PYTHON_API_VERSION).
|
||||
These flags are used to change expected features and behavior for a
|
||||
particular type.
|
||||
|
||||
Arbitration of the flag bit positions will need to be coordinated among
|
||||
all extension writers who publicly release their extensions (this will
|
||||
be fewer than you might expect!)..
|
||||
be fewer than you might expect!).
|
||||
|
||||
Most flags were removed as of Python 3.0 to make room for new flags. (Some
|
||||
flags are not for backwards compatibility but to indicate the presence of an
|
||||
|
@ -302,7 +299,7 @@ given type object has a specified feature.
|
|||
/* Set while the type is being 'readied', to prevent recursive ready calls */
|
||||
#define Py_TPFLAGS_READYING (1UL << 13)
|
||||
|
||||
/* Objects support garbage collection (see objimp.h) */
|
||||
/* Objects support garbage collection (see objimpl.h) */
|
||||
#define Py_TPFLAGS_HAVE_GC (1UL << 14)
|
||||
|
||||
/* These two bits are preserved for Stackless Python, next after this is 17 */
|
||||
|
@ -340,6 +337,11 @@ given type object has a specified feature.
|
|||
/* NOTE: The following flags reuse lower bits (removed as part of the
|
||||
* Python 3.0 transition). */
|
||||
|
||||
/* The following flag is kept for compatibility. Starting with 3.8,
|
||||
* binary compatibility of C extensions accross feature releases of
|
||||
* Python is not supported anymore, except when using the stable ABI.
|
||||
*/
|
||||
|
||||
/* Type structure has tp_finalize member (3.4) */
|
||||
#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue