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>
This commit is contained in:
ram vikram singh 2023-01-24 14:59:22 +05:30 committed by GitHub
parent e244401ce5
commit 7f95ec3e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View File

@ -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
------------------------------

View File

@ -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;

View File

@ -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.

View File

@ -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");