Skip to content

Commit fc618e1

Browse files
committed
Fixed KeyError when invalidating the cache for field that were not previously requested.
1 parent 258c105 commit fc618e1

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/core/modules/core/core_cache.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,16 @@ void CCachedProperty::__set__(object instance, object value)
198198
if (!result.is_none())
199199
cache[m_name] = _prepare_value(result);
200200
else
201-
cache[m_name].del();
201+
{
202+
try
203+
{
204+
cache[m_name].del();
205+
}
206+
catch (...)
207+
{
208+
PyErr_Clear();
209+
}
210+
}
202211
}
203212

204213
void CCachedProperty::__delete__(object instance)
@@ -210,7 +219,14 @@ void CCachedProperty::__delete__(object instance)
210219
);
211220

212221
dict cache = extract<dict>(instance.attr("__dict__"));
213-
cache[m_name].del();
222+
try
223+
{
224+
cache[m_name].del();
225+
}
226+
catch (...)
227+
{
228+
PyErr_Clear();
229+
}
214230
}
215231

216232
object CCachedProperty::__call__(object self, object fget)

0 commit comments

Comments
 (0)