Skip to content

Commit 17849df

Browse files
encukoulkollar
authored andcommitted
pythongh-137210: Move PYTHON_API_VERSION & PYTHON_ABI_VERSION to patchlevel.h (pythonGH-138545)
Move PYTHON_API_VERSION & PYTHON_ABI_VERSION to patchlevel.h This allows removing #include "modsupport.h" from python_ver_rc.h, which allows modsupport.h to use common helpers from Python.h -- specifically, `_Py_PACK_VERSION` for defining limited API.
1 parent bd605bf commit 17849df

File tree

3 files changed

+16
-54
lines changed

3 files changed

+16
-54
lines changed

Include/modsupport.h

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -56,58 +56,6 @@ PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
5656

5757
#define Py_CLEANUP_SUPPORTED 0x20000
5858

59-
#define PYTHON_API_VERSION 1013
60-
#define PYTHON_API_STRING "1013"
61-
/* The API version is maintained (independently from the Python version)
62-
so we can detect mismatches between the interpreter and dynamically
63-
loaded modules. These are diagnosed by an error message but
64-
the module is still loaded (because the mismatch can only be tested
65-
after loading the module). The error message is intended to
66-
explain the core dump a few seconds later.
67-
68-
The symbol PYTHON_API_STRING defines the same value as a string
69-
literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. ***
70-
71-
Please add a line or two to the top of this log for each API
72-
version change:
73-
74-
22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths
75-
76-
19-Aug-2002 GvR 1012 Changes to string object struct for
77-
interning changes, saving 3 bytes.
78-
79-
17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side
80-
81-
25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and
82-
PyFrame_New(); Python 2.1a2
83-
84-
14-Mar-2000 GvR 1009 Unicode API added
85-
86-
3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!)
87-
88-
3-Dec-1998 GvR 1008 Python 1.5.2b1
89-
90-
18-Jan-1997 GvR 1007 string interning and other speedups
91-
92-
11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-(
93-
94-
30-Jul-1996 GvR Slice and ellipses syntax added
95-
96-
23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-)
97-
98-
7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( )
99-
100-
10-Jan-1995 GvR Renamed globals to new naming scheme
101-
102-
9-Jan-1995 GvR Initial version (incompatible with older API)
103-
*/
104-
105-
/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
106-
Python 3, it will stay at the value of 3; changes to the limited API
107-
must be performed in a strictly backwards-compatible manner. */
108-
#define PYTHON_ABI_VERSION 3
109-
#define PYTHON_ABI_STRING "3"
110-
11159
PyAPI_FUNC(PyObject *) PyModule_Create2(PyModuleDef*, int apiver);
11260

11361
#ifdef Py_LIMITED_API
@@ -135,7 +83,7 @@ PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
13583
#endif /* New in 3.5 */
13684

13785
/* ABI info & checking (new in 3.15) */
138-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030f0000
86+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 15)
13987
typedef struct PyABIInfo {
14088
uint8_t abiinfo_major_version;
14189
uint8_t abiinfo_minor_version;

Include/patchlevel.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
configure.ac must also be changed.
77
88
There is also (independent) API version information in modsupport.h.
9+
10+
This header should self-contained; PC/python_ver_rc.h includes it
11+
without the rest of Python.h.
912
*/
1013

1114
/* Values for PY_RELEASE_LEVEL */
@@ -46,4 +49,16 @@
4649

4750
// Public Py_PACK_VERSION is declared in pymacro.h; it needs <inttypes.h>.
4851

52+
53+
/* The API and ABI versions are left for backwards compatibility.
54+
They've not been updated since 2006 and 2010, respectively.
55+
API/ABI versioning is now tied to the CPython version.
56+
The *_VERSION and *_STRING symbols should define the same value; as
57+
number and string literal respectively. Make sure the definitions match.
58+
*/
59+
#define PYTHON_API_VERSION 1013
60+
#define PYTHON_API_STRING "1013"
61+
#define PYTHON_ABI_VERSION 3
62+
#define PYTHON_ABI_STRING "3"
63+
4964
#endif //_Py_PATCHLEVEL_H

PC/python_ver_rc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define PYTHON_COPYRIGHT "Copyright \xA9 2001 Python Software Foundation. Copyright \xA9 2000 BeOpen.com. Copyright \xA9 1995-2001 CNRI. Copyright \xA9 1991-1995 SMC."
99

1010
#define MS_WINDOWS
11-
#include "modsupport.h"
1211
#include "patchlevel.h"
1312
#ifdef Py_DEBUG
1413
# define PYTHON_DEBUG_EXT "_d"

0 commit comments

Comments
 (0)