MCPcopy Create free account
hub / github.com/pybind/pybind11 / dict_setdefaultstring

Function dict_setdefaultstring

include/pybind11/pytypes.h:1018–1030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1016}
1017
1018inline PyObject *dict_setdefaultstring(PyObject *v, const char *key, PyObject *defaultobj) {
1019 PyObject *kv = PyUnicode_FromString(key);
1020 if (kv == nullptr) {
1021 throw error_already_set();
1022 }
1023
1024 PyObject *rv = PyDict_SetDefault(v, kv, defaultobj);
1025 Py_DECREF(kv);
1026 if (rv == nullptr) {
1027 throw error_already_set();
1028 }
1029 return rv;
1030}
1031
1032// PyDict_SetDefaultRef was added in Python 3.13.0a4.
1033// See also: https://github.com/python/pythoncapi-compat/blob/main/pythoncapi_compat.h

Callers 2

dict_setdefaultstringrefFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected