diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-04 09:21:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 09:21:47 (GMT) |
commit | 5a79d2ae572fed03eb9b9554b2760a34e75191a7 (patch) | |
tree | e84af8e19438eb37189ea0586a2e3e444551dd3f /Modules | |
parent | 44fc378b598eb675a847d1b7c46c8f6e81313c04 (diff) | |
download | cpython-5a79d2ae572fed03eb9b9554b2760a34e75191a7.zip cpython-5a79d2ae572fed03eb9b9554b2760a34e75191a7.tar.gz cpython-5a79d2ae572fed03eb9b9554b2760a34e75191a7.tar.bz2 |
Revert "gh-46376: Return existing pointer when possible in ctypes (#1… (#108688)
This reverts commit 08447b5deb47e2a0df87fa0a0576d300e5c909b4.
Revert also _ctypes.c changes of the PyDict_ContainsString() change,
commit 67266266469fe0e817736227f39537182534c1a5.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index ed9efca..3af3a80 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5148,41 +5148,6 @@ Pointer_get_contents(CDataObject *self, void *closure) stgdict = PyObject_stgdict((PyObject *)self); assert(stgdict); /* Cannot be NULL for pointer instances */ - - PyObject *keep = GetKeepedObjects(self); - if (keep != NULL) { - // check if it's a pointer to a pointer: - // pointers will have '0' key in the _objects - int ptr_probe = PyDict_ContainsString(keep, "0"); - if (ptr_probe < 0) { - return NULL; - } - if (ptr_probe) { - PyObject *item; - if (PyDict_GetItemStringRef(keep, "1", &item) < 0) { - return NULL; - } - if (item == NULL) { - PyErr_SetString(PyExc_ValueError, - "Unexpected NULL pointer in _objects"); - return NULL; - } -#ifndef NDEBUG - CDataObject *ptr2ptr = (CDataObject *)item; - // Don't construct a new object, - // return existing one instead to preserve refcount. - // Double-check that we are returning the same thing. - assert( - *(void**) self->b_ptr == ptr2ptr->b_ptr || - *(void**) self->b_value.c == ptr2ptr->b_ptr || - *(void**) self->b_ptr == ptr2ptr->b_value.c || - *(void**) self->b_value.c == ptr2ptr->b_value.c - ); -#endif - return item; - } - } - return PyCData_FromBaseObj(stgdict->proto, (PyObject *)self, 0, *(void **)self->b_ptr); |