]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101152: Implement PEP 699 (GH-101193)
authorram vikram singh <ramvikrams243@gmail.com>
Tue, 24 Jan 2023 09:29:22 +0000 (14:59 +0530)
committerGitHub <noreply@github.com>
Tue, 24 Jan 2023 09:29:22 +0000 (17:29 +0800)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Doc/whatsnew/3.12.rst
Include/cpython/dictobject.h
Misc/NEWS.d/next/Build/2023-01-21-10-31-35.gh-issue-101152.xvM8pL.rst [new file with mode: 0644]
Modules/_testcapimodule.c

index 3cab89712451d41963b316e9ed789a9ae0a999c4..2f9ca1102d3d1b1f72ba12797c32dcb0212e4a7c 100644 (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
 ------------------------------
index 2dff59ef0b8a6b89f5f5c04727f03a847438bf9e..5001f35654475e6c6468dcaf764bbe31b9ab84ab 100644 (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;
 
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 (file)
index 0000000..e35b617
--- /dev/null
@@ -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.
index 486988b4e34cdd665795accefbe91355488446b8..46c025bf53404a2da6333d225db842fa02549059 100644 (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");