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

Function dict_getitemstringref

include/pybind11/pytypes.h:1001–1016  ·  view source on GitHub ↗

PyDict_GetItemStringRef was added in Python 3.13.0a1. See also: https://github.com/python/pythoncapi-compat/blob/main/pythoncapi_compat.h

Source from the content-addressed store, hash-verified

999// PyDict_GetItemStringRef was added in Python 3.13.0a1.
1000// See also: https://github.com/python/pythoncapi-compat/blob/main/pythoncapi_compat.h
1001inline PyObject *dict_getitemstringref(PyObject *v, const char *key) {
1002#if PY_VERSION_HEX >= 0x030D00A1
1003 PyObject *rv = nullptr;
1004 if (PyDict_GetItemStringRef(v, key, &rv) < 0) {
1005 throw error_already_set();
1006 }
1007 return rv;
1008#else
1009 PyObject *rv = dict_getitemstring(v, key);
1010 if (rv == nullptr && PyErr_Occurred()) {
1011 throw error_already_set();
1012 }
1013 Py_XINCREF(rv);
1014 return rv;
1015#endif
1016}
1017
1018inline PyObject *dict_setdefaultstring(PyObject *v, const char *key, PyObject *defaultobj) {
1019 PyObject *kv = PyUnicode_FromString(key);

Callers

nothing calls this directly

Calls 1

dict_getitemstringFunction · 0.85

Tested by

no test coverage detected