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

Function get_python_state_dict

include/pybind11/detail/internals.h:159–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159inline object get_python_state_dict() {
160 object state_dict;
161#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
162 state_dict = reinterpret_borrow<object>(PyEval_GetBuiltins());
163#else
164 auto *istate = get_interpreter_state_unchecked();
165 if (istate) {
166 state_dict = reinterpret_borrow<object>(PyInterpreterState_GetDict(istate));
167 }
168#endif
169 if (!state_dict) {
170 raise_from(PyExc_SystemError, "pybind11::detail::get_python_state_dict() FAILED");
171 throw error_already_set();
172 }
173 return state_dict;
174}
175
176// Python loads modules by default with dlopen with the RTLD_LOCAL flag; under libc++ and possibly
177// other STLs, this means `typeid(A)` from one module won't equal `typeid(A)` from another module

Callers 6

get_cached_moduleFunction · 0.85
cache_completed_moduleFunction · 0.85
get_internals_capsuleFunction · 0.85

Calls 2

raise_fromFunction · 0.85

Tested by 1