Skip to content

Commit afa0bad

Browse files
pythongh-141726: Add PyDict_SetDefaultRef() to the Stable ABI (python#141727)
Co-authored-by: Stan Ulbrych <[email protected]>
1 parent 52f70a6 commit afa0bad

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/cpython/dictobject.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ Py_DEPRECATED(3.14) PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObje
3939
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
4040
PyObject *mp, PyObject *key, PyObject *defaultobj);
4141

42-
// Inserts `key` with a value `default_value`, if `key` is not already present
43-
// in the dictionary. If `result` is not NULL, then the value associated
44-
// with `key` is returned in `*result` (either the existing value, or the now
45-
// inserted `default_value`).
46-
// Returns:
47-
// -1 on error
48-
// 0 if `key` was not present and `default_value` was inserted
49-
// 1 if `key` was present and `default_value` was not inserted
50-
PyAPI_FUNC(int) PyDict_SetDefaultRef(PyObject *mp, PyObject *key, PyObject *default_value, PyObject **result);
51-
5242
/* Get the number of items of a dictionary. */
5343
static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) {
5444
PyDictObject *mp;

Include/dictobject.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ PyAPI_FUNC(int) PyDict_GetItemRef(PyObject *mp, PyObject *key, PyObject **result
6868
PyAPI_FUNC(int) PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject **result);
6969
#endif
7070

71+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030F0000
72+
// Inserts `key` with a value `default_value`, if `key` is not already present
73+
// in the dictionary. If `result` is not NULL, then the value associated
74+
// with `key` is returned in `*result` (either the existing value, or the now
75+
// inserted `default_value`).
76+
// Returns:
77+
// -1 on error
78+
// 0 if `key` was not present and `default_value` was inserted
79+
// 1 if `key` was present and `default_value` was not inserted
80+
PyAPI_FUNC(int) PyDict_SetDefaultRef(PyObject *mp, PyObject *key, PyObject *default_value, PyObject **result);
81+
#endif
82+
7183
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
7284
PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
7385
#endif

Lib/test/test_stable_abi_ctypes.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add :c:func:`PyDict_SetDefaultRef` to the Stable ABI.

Misc/stable_abi.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,3 +2639,5 @@
26392639
added = '3.15'
26402640
[const.Py_mod_token]
26412641
added = '3.15'
2642+
[function.PyDict_SetDefaultRef]
2643+
added = '3.15'

PC/python3dll.c

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)