summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-08-04 12:03:07 (GMT)
committerGitHub <noreply@github.com>2022-08-04 12:03:07 (GMT)
commit312dab29a3f83940c501caadda9e653e1c7209b1 (patch)
treeae6a64b8a6656cee443452181e7dd809c79a1781
parent2ab560105b9bfda503148e66e58d1d9a6031745e (diff)
downloadcpython-312dab29a3f83940c501caadda9e653e1c7209b1.zip
cpython-312dab29a3f83940c501caadda9e653e1c7209b1.tar.gz
cpython-312dab29a3f83940c501caadda9e653e1c7209b1.tar.bz2
Revert "[3.11] GH-92678: Expose managed dict clear and visit functions (GH-95246). (#95256)" (#95647)
This reverts commit 7f731943393d57cf26ed5f2353e6e53084cd55fd.
-rw-r--r--Include/cpython/dictobject.h3
-rw-r--r--Lib/test/test_capi.py14
-rw-r--r--Modules/_testcapimodule.c9
-rw-r--r--Objects/dictobject.c29
4 files changed, 0 insertions, 55 deletions
diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h
index b586f75..033eaeb 100644
--- a/Include/cpython/dictobject.h
+++ b/Include/cpython/dictobject.h
@@ -76,6 +76,3 @@ typedef struct {
PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
-
-PyAPI_FUNC(int) _PyObject_VisitManagedDict(PyObject *self, visitproc visit, void *arg);
-PyAPI_FUNC(void) _PyObject_ClearManagedDict(PyObject *self);
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 7d766ec..40750cc 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -724,20 +724,6 @@ class CAPITest(unittest.TestCase):
with self.subTest(name=name):
self.assertTrue(hasattr(ctypes.pythonapi, name))
- def test_clear_managed_dict(self):
-
- class C:
- def __init__(self):
- self.a = 1
-
- c = C()
- _testcapi.clear_managed_dict(c)
- self.assertEqual(c.__dict__, {})
- c = C()
- self.assertEqual(c.__dict__, {'a':1})
- _testcapi.clear_managed_dict(c)
- self.assertEqual(c.__dict__, {})
-
class TestPendingCalls(unittest.TestCase):
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index a394f46..b0a4687 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -6014,14 +6014,6 @@ settrace_to_record(PyObject *self, PyObject *list)
Py_RETURN_NONE;
}
-static PyObject *
-clear_managed_dict(PyObject *self, PyObject *obj)
-{
- _PyObject_ClearManagedDict(obj);
- Py_RETURN_NONE;
-}
-
-
static PyObject *negative_dictoffset(PyObject *, PyObject *);
static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *);
static PyObject *getargs_s_hash_int(PyObject *, PyObject *, PyObject*);
@@ -6323,7 +6315,6 @@ static PyMethodDef TestMethods[] = {
{"get_feature_macros", get_feature_macros, METH_NOARGS, NULL},
{"test_code_api", test_code_api, METH_NOARGS, NULL},
{"settrace_to_record", settrace_to_record, METH_O, NULL},
- {"clear_managed_dict", clear_managed_dict, METH_O, NULL},
{NULL, NULL} /* sentinel */
};
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 25e191f..ebbd22e 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -5583,35 +5583,6 @@ _PyObject_FreeInstanceAttributes(PyObject *self)
free_values(*values_ptr);
}
-int
-_PyObject_VisitManagedDict(PyObject *self, visitproc visit, void *arg)
-{
- PyTypeObject *tp = Py_TYPE(self);
- if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
- return 0;
- }
- assert(tp->tp_dictoffset);
- int err = _PyObject_VisitInstanceAttributes(self, visit, arg);
- if (err) {
- return err;
- }
- Py_VISIT(*_PyObject_ManagedDictPointer(self));
- return 0;
-}
-
-
-void
-_PyObject_ClearManagedDict(PyObject *self)
-{
- PyTypeObject *tp = Py_TYPE(self);
- if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
- return;
- }
- _PyObject_FreeInstanceAttributes(self);
- *_PyObject_ValuesPointer(self) = NULL;
- Py_CLEAR(*_PyObject_ManagedDictPointer(self));
-}
-
PyObject *
PyObject_GenericGetDict(PyObject *obj, void *context)
{