Add comment explaining error_scope usage

Clarify why error_scope is used: to preserve any existing Python
error state that might be cleared or modified by dict_getitemstringref.
This commit is contained in:
Ralf W. Grosse-Kunstleve
2025-12-19 21:57:36 -08:00
parent a4d4d73486
commit 7cb30ceb07

View File

@@ -236,6 +236,9 @@ private:
}
static call_once_storage_map_type *get_or_create_call_once_storage_map() {
// Preserve any existing Python error state. dict_getitemstringref may clear
// errors or set new ones when the key is not found; we restore the original
// error state when this scope exits.
error_scope err_scope;
dict state_dict = detail::get_python_state_dict();
auto storage_map_obj = reinterpret_steal<object>(