[Python-checkins] bpo-41845: Move PyObject_GenericGetDict() back into the limited API (GH22646)

Zackery Spytz webhook-mailer at python.org
Mon Oct 19 18:47:45 EDT 2020


https://github.com/python/cpython/commit/1438c2ac773e87d1f9c97fc22f2346e16bf48773
commit: 1438c2ac773e87d1f9c97fc22f2346e16bf48773
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-10-19T23:47:37+01:00
summary:

bpo-41845: Move PyObject_GenericGetDict() back into the limited API (GH22646)

It was moved out of the limited API in 7d95e4072169911b228c9e42367afb5f17fd3db0.
This change re-enables it from 3.10, to avoid generating invalid extension modules for earlier versions.

files:
A Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst
M Include/cpython/dictobject.h
M Include/dictobject.h
M PC/python3dll.c

diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h
index ffe0e97fb35f3..5a15630cfbac7 100644
--- a/Include/cpython/dictobject.h
+++ b/Include/cpython/dictobject.h
@@ -41,7 +41,6 @@ PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
 PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
                                   int (*predicate)(PyObject *value));
 PyDictKeysObject *_PyDict_NewKeysForClass(void);
-PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
 PyAPI_FUNC(int) _PyDict_Next(
     PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
 
diff --git a/Include/dictobject.h b/Include/dictobject.h
index c88b0aa0a5d0f..da5a36ba07f32 100644
--- a/Include/dictobject.h
+++ b/Include/dictobject.h
@@ -57,6 +57,9 @@ PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
 PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
 PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
 PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
+PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
+#endif
 
 /* Dictionary (keys, values, items) views */
 
diff --git a/Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst b/Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst
new file mode 100644
index 0000000000000..31d3154c3c60e
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst	
@@ -0,0 +1,2 @@
+:c:func:`PyObject_GenericGetDict` is available again in the limited API
+when targeting 3.10 or later.
diff --git a/PC/python3dll.c b/PC/python3dll.c
index b9b229ea67d7b..7e4a510177304 100644
--- a/PC/python3dll.c
+++ b/PC/python3dll.c
@@ -414,6 +414,7 @@ EXPORT_FUNC(PyObject_GC_Track)
 EXPORT_FUNC(PyObject_GC_UnTrack)
 EXPORT_FUNC(PyObject_GenericGetAttr)
 EXPORT_FUNC(PyObject_GenericSetAttr)
+EXPORT_FUNC(PyObject_GenericGetDict)
 EXPORT_FUNC(PyObject_GenericSetDict)
 EXPORT_FUNC(PyObject_GetAttr)
 EXPORT_FUNC(PyObject_GetAttrString)



More information about the Python-checkins mailing list