From 794eb8a4bfe8a1eb52088787593a978045183254 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 25 Oct 2023 10:08:16 +0200 Subject: [PATCH] gh-111262: Re-add _PyDict_Pop() to have a C-API until a new public one is designed. --- Include/cpython/dictobject.h | 1 + Include/internal/pycore_dict.h | 3 --- Modules/_threadmodule.c | 1 - Modules/socketmodule.c | 1 - Python/import.c | 1 - 5 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h index b05ca3ef453816..64a40425ba7714 100644 --- a/Include/cpython/dictobject.h +++ b/Include/cpython/dictobject.h @@ -46,6 +46,7 @@ static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { PyAPI_FUNC(int) PyDict_ContainsString(PyObject *mp, const char *key); +PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *dict, PyObject *key, PyObject *default_value); /* Dictionary watchers */ diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h index 47b5948f66343a..d01ef55de51f5d 100644 --- a/Include/internal/pycore_dict.h +++ b/Include/internal/pycore_dict.h @@ -49,9 +49,6 @@ extern PyObject* _PyDict_NewPresized(Py_ssize_t minused); // Export for '_ctypes' shared extension PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *); -// Export for '_socket' shared extension (Windows remove_unusable_flags()) -PyAPI_FUNC(PyObject*) _PyDict_Pop(PyObject *, PyObject *, PyObject *); - #define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL) /* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0, diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 4d453040503643..a849a200df625c 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -3,7 +3,6 @@ /* Interface to Sjoerd's portable C thread library */ #include "Python.h" -#include "pycore_dict.h" // _PyDict_Pop() #include "pycore_interp.h" // _PyInterpreterState.threads.count #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg() diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 3d099d41d1e761..b6e91f8805d4bf 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -107,7 +107,6 @@ Local naming conventions: #include "Python.h" #include "pycore_capsule.h" // _PyCapsule_SetTraverse() -#include "pycore_dict.h" // _PyDict_Pop() #include "pycore_fileutils.h" // _Py_set_inheritable() #include "pycore_moduleobject.h" // _PyModule_GetState diff --git a/Python/import.c b/Python/import.c index cafdd834502224..9aee7aa0e4d1f1 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1,7 +1,6 @@ /* Module definition and import implementation */ #include "Python.h" -#include "pycore_dict.h" // _PyDict_Pop() #include "pycore_hashtable.h" // _Py_hashtable_new_full() #include "pycore_import.h" // _PyImport_BootstrapImp() #include "pycore_initconfig.h" // _PyStatus_OK()