|
1 | 1 | #include "parts.h" |
2 | 2 | #include "util.h" |
3 | 3 | |
4 | | - |
5 | 4 | static PyObject * |
6 | 5 | dict_containsstring(PyObject *self, PyObject *args) |
7 | 6 | { |
@@ -182,6 +181,18 @@ dict_popstring_null(PyObject *self, PyObject *args)
|
182 | 181 | RETURN_INT(PyDict_PopString(dict, key, NULL)); |
183 | 182 | } |
184 | 183 | |
| 184 | +static PyObject * |
| 185 | +dict_version(PyObject *self, PyObject *dict) |
| 186 | +{ |
| 187 | +if (!PyDict_Check(dict)) { |
| 188 | +PyErr_SetString(PyExc_TypeError, "expected dict"); |
| 189 | +return NULL; |
| 190 | + } |
| 191 | +_Py_COMP_DIAG_PUSH |
| 192 | +_Py_COMP_DIAG_IGNORE_DEPR_DECLS |
| 193 | +return PyLong_FromUnsignedLongLong(((PyDictObject *)dict)->ma_version_tag); |
| 194 | +_Py_COMP_DIAG_POP |
| 195 | +} |
185 | 196 | |
186 | 197 | static PyMethodDef test_methods[] = { |
187 | 198 | {"dict_containsstring", dict_containsstring, METH_VARARGS}, |
@@ -193,6 +204,7 @@ static PyMethodDef test_methods[] = {
|
193 | 204 | {"dict_pop_null", dict_pop_null, METH_VARARGS}, |
194 | 205 | {"dict_popstring", dict_popstring, METH_VARARGS}, |
195 | 206 | {"dict_popstring_null", dict_popstring_null, METH_VARARGS}, |
| 207 | + {"dict_version", dict_version, METH_O}, |
196 | 208 | {NULL}, |
197 | 209 | }; |
198 | 210 | |
|