summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-09-08 19:51:24 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-09-08 19:51:24 (GMT)
commit3b6a6b4215950bce2a3b4bfc7d1876ab11e5f591 (patch)
treeea9d0eb92290e7565280d82bb1e2f92f5a38fb83 /Modules/_testcapimodule.c
parent70897ec54c824bc66ae15678e0dc8da144227582 (diff)
downloadcpython-3b6a6b4215950bce2a3b4bfc7d1876ab11e5f591.zip
cpython-3b6a6b4215950bce2a3b4bfc7d1876ab11e5f591.tar.gz
cpython-3b6a6b4215950bce2a3b4bfc7d1876ab11e5f591.tar.bz2
Add a new private version to the builtin dict type
Issue #26058: Add a new private version to the builtin dict type, incremented at each dictionary creation and at each dictionary change. Implementation of the PEP 509.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 7d7fa40..b5b8f1a 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -3915,6 +3915,21 @@ tracemalloc_get_traceback(PyObject *self, PyObject *args)
return _PyTraceMalloc_GetTraceback(domain, (uintptr_t)ptr);
}
+static PyObject *
+dict_get_version(PyObject *self, PyObject *args)
+{
+ PyDictObject *dict;
+ uint64_t version;
+
+ if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
+ return NULL;
+
+ version = dict->ma_version_tag;
+
+ Py_BUILD_ASSERT(sizeof(unsigned PY_LONG_LONG) >= sizeof(version));
+ return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)version);
+}
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
@@ -4114,6 +4129,7 @@ static PyMethodDef TestMethods[] = {
{"tracemalloc_track", tracemalloc_track, METH_VARARGS},
{"tracemalloc_untrack", tracemalloc_untrack, METH_VARARGS},
{"tracemalloc_get_traceback", tracemalloc_get_traceback, METH_VARARGS},
+ {"dict_get_version", dict_get_version, METH_VARARGS},
{NULL, NULL} /* sentinel */
};