gh-141726: Add PyDict_SetDefaultRef() to the Stable ABI (#141727) · python/cpython@afa0bad

GitHub

Original file line numberDiff line numberDiff line change@@ -39,16 +39,6 @@ Py_DEPRECATED(3.14) PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObje

3939PyAPI_FUNC(PyObject*) PyDict_SetDefault(

4040PyObject*mp, PyObject*key, PyObject*defaultobj);

414142-// 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. */

5343staticinlinePy_ssize_tPyDict_GET_SIZE(PyObject*op) {

5444PyDictObject*mp;

Original file line numberDiff line numberDiff line change@@ -68,6 +68,18 @@ PyAPI_FUNC(int) PyDict_GetItemRef(PyObject *mp, PyObject *key, PyObject **result

6868PyAPI_FUNC(int) PyDict_GetItemStringRef(PyObject*mp, constchar*key, PyObject**result);

6969#endif

707071+#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

7284PyAPI_FUNC(PyObject*) PyObject_GenericGetDict(PyObject*, void*);

7385#endif

Original file line numberDiff line numberDiff line change@@ -0,0 +1 @@

1+Add :c:func:`PyDict_SetDefaultRef` to the Stable ABI.

Original file line numberDiff line numberDiff line change@@ -2639,3 +2639,5 @@

26392639added = '3.15'

26402640[const.Py_mod_token]

26412641added = '3.15'

2642+[function.PyDict_SetDefaultRef]

2643+added = '3.15'