diff options
author | ram vikram singh <ramvikrams243@gmail.com> | 2023-01-24 09:29:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 09:29:22 (GMT) |
commit | 7f95ec3e7405ea5f44adc3584e297a3191118f32 (patch) | |
tree | ae210c0f81259d13593badc52ee9d09d8c06f178 | |
parent | e244401ce508ad391295beb636e499fcc6797a2a (diff) | |
download | cpython-7f95ec3e7405ea5f44adc3584e297a3191118f32.zip cpython-7f95ec3e7405ea5f44adc3584e297a3191118f32.tar.gz cpython-7f95ec3e7405ea5f44adc3584e297a3191118f32.tar.bz2 |
gh-101152: Implement PEP 699 (GH-101193)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Ken Jin <kenjin@python.org>
-rw-r--r-- | Doc/whatsnew/3.12.rst | 5 | ||||
-rw-r--r-- | Include/cpython/dictobject.h | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Build/2023-01-21-10-31-35.gh-issue-101152.xvM8pL.rst | 3 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 3 |
4 files changed, 15 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 3cab897..2f9ca11 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -430,6 +430,11 @@ Deprecated Before, the Python implementation emitted :exc:`FutureWarning`, and the C implementation emitted nothing. +* In accordance with :pep:`699`, the ``ma_version_tag`` field in :c:type:`PyDictObject` + is deprecated for extension modules. Accessing this field will generate a compiler + warning at compile time. This field will be removed in Python 3.14. + (Contributed by Ramvikrams and Kumar Aditya in :gh:`101193`. PEP by Ken Jin.) + Pending Removal in Python 3.13 ------------------------------ diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h index 2dff59e..5001f35 100644 --- a/Include/cpython/dictobject.h +++ b/Include/cpython/dictobject.h @@ -16,7 +16,11 @@ typedef struct { /* Dictionary version: globally unique, value change each time the dictionary is modified */ +#ifdef Py_BUILD_CORE uint64_t ma_version_tag; +#else + Py_DEPRECATED(3.12) uint64_t ma_version_tag; +#endif PyDictKeysObject *ma_keys; diff --git a/Misc/NEWS.d/next/Build/2023-01-21-10-31-35.gh-issue-101152.xvM8pL.rst b/Misc/NEWS.d/next/Build/2023-01-21-10-31-35.gh-issue-101152.xvM8pL.rst new file mode 100644 index 0000000..e35b617 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-01-21-10-31-35.gh-issue-101152.xvM8pL.rst @@ -0,0 +1,3 @@ +In accordance with :PEP:`699`, the ``ma_version_tag`` field in :c:type:`PyDictObject` +is deprecated for extension modules. Accessing this field will generate a compiler +warning at compile time. This field will be removed in Python 3.14. diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 486988b..46c025b 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2148,7 +2148,10 @@ dict_get_version(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict)) return NULL; + _Py_COMP_DIAG_PUSH + _Py_COMP_DIAG_IGNORE_DEPR_DECLS version = dict->ma_version_tag; + _Py_COMP_DIAG_POP static_assert(sizeof(unsigned long long) >= sizeof(version), "version is larger than unsigned long long"); |