Skip to content

Commit 5dc94e7

Browse files
authored
Revert "[3.11] GH-92678: Expose managed dict clear and visit functions (GH-95246). (#95256)"
This reverts commit 7f73194.
1 parent 2ab5601 commit 5dc94e7

File tree

4 files changed

+0
-55
lines changed

4 files changed

+0
-55
lines changed

Include/cpython/dictobject.h

-3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,3 @@ typedef struct {
7676

7777
PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
7878
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
79-
80-
PyAPI_FUNC(int) _PyObject_VisitManagedDict(PyObject *self, visitproc visit, void *arg);
81-
PyAPI_FUNC(void) _PyObject_ClearManagedDict(PyObject *self);

Lib/test/test_capi.py

-14
Original file line numberDiff line numberDiff line change
@@ -724,20 +724,6 @@ def test_export_symbols(self):
724724
with self.subTest(name=name):
725725
self.assertTrue(hasattr(ctypes.pythonapi, name))
726726

727-
def test_clear_managed_dict(self):
728-
729-
class C:
730-
def __init__(self):
731-
self.a = 1
732-
733-
c = C()
734-
_testcapi.clear_managed_dict(c)
735-
self.assertEqual(c.__dict__, {})
736-
c = C()
737-
self.assertEqual(c.__dict__, {'a':1})
738-
_testcapi.clear_managed_dict(c)
739-
self.assertEqual(c.__dict__, {})
740-
741727

742728
class TestPendingCalls(unittest.TestCase):
743729

Modules/_testcapimodule.c

-9
Original file line numberDiff line numberDiff line change
@@ -6014,14 +6014,6 @@ settrace_to_record(PyObject *self, PyObject *list)
60146014
Py_RETURN_NONE;
60156015
}
60166016

6017-
static PyObject *
6018-
clear_managed_dict(PyObject *self, PyObject *obj)
6019-
{
6020-
_PyObject_ClearManagedDict(obj);
6021-
Py_RETURN_NONE;
6022-
}
6023-
6024-
60256017
static PyObject *negative_dictoffset(PyObject *, PyObject *);
60266018
static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *);
60276019
static PyObject *getargs_s_hash_int(PyObject *, PyObject *, PyObject*);
@@ -6323,7 +6315,6 @@ static PyMethodDef TestMethods[] = {
63236315
{"get_feature_macros", get_feature_macros, METH_NOARGS, NULL},
63246316
{"test_code_api", test_code_api, METH_NOARGS, NULL},
63256317
{"settrace_to_record", settrace_to_record, METH_O, NULL},
6326-
{"clear_managed_dict", clear_managed_dict, METH_O, NULL},
63276318
{NULL, NULL} /* sentinel */
63286319
};
63296320

Objects/dictobject.c

-29
Original file line numberDiff line numberDiff line change
@@ -5583,35 +5583,6 @@ _PyObject_FreeInstanceAttributes(PyObject *self)
55835583
free_values(*values_ptr);
55845584
}
55855585

5586-
int
5587-
_PyObject_VisitManagedDict(PyObject *self, visitproc visit, void *arg)
5588-
{
5589-
PyTypeObject *tp = Py_TYPE(self);
5590-
if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
5591-
return 0;
5592-
}
5593-
assert(tp->tp_dictoffset);
5594-
int err = _PyObject_VisitInstanceAttributes(self, visit, arg);
5595-
if (err) {
5596-
return err;
5597-
}
5598-
Py_VISIT(*_PyObject_ManagedDictPointer(self));
5599-
return 0;
5600-
}
5601-
5602-
5603-
void
5604-
_PyObject_ClearManagedDict(PyObject *self)
5605-
{
5606-
PyTypeObject *tp = Py_TYPE(self);
5607-
if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
5608-
return;
5609-
}
5610-
_PyObject_FreeInstanceAttributes(self);
5611-
*_PyObject_ValuesPointer(self) = NULL;
5612-
Py_CLEAR(*_PyObject_ManagedDictPointer(self));
5613-
}
5614-
56155586
PyObject *
56165587
PyObject_GenericGetDict(PyObject *obj, void *context)
56175588
{

0 commit comments

Comments
 (0)