Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ad6e47

Browse files
committed
Check the type of the exception before ignoring it
1 parent 293d013 commit 4ad6e47

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/runtime/classmanager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,13 @@ internal static void SaveRuntimeData(RuntimeDataStorage storage)
110110
// No need to decref the member, the ClassBase instance does
111111
// not own the reference.
112112
Runtime.PyDict_DelItemString(dict, member);
113+
if (Exceptions.ExceptionMatches(Exceptions.KeyError))
114+
{
115+
// Trying to remove a key that's not in the dictionary
116+
// raises an error. We don't care about it.
117+
Runtime.PyErr_Clear();
118+
}
113119
}
114-
// Trying to remove a key that's not in the dictionary may
115-
// raise an error. We don't care about it.
116-
Runtime.PyErr_Clear();
117120
// We modified the Type object, notify it we did.
118121
Runtime.PyType_Modified(cls.Value.tpHandle);
119122
}

src/runtime/moduleobject.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,13 @@ protected override void OnSave(InterDomainContext context)
346346
{
347347
Runtime.PyDict_DelItemString(dict, pair.Key);
348348
pair.Value.DecrRefCount();
349+
if (Exceptions.ExceptionMatches(Exceptions.KeyError))
350+
{
351+
// Trying to remove a key that's not in the dictionary
352+
// raises an error. We don't care about it.
353+
Runtime.PyErr_Clear();
354+
}
349355
}
350-
// Trying to remove a key that's not in the dictionary may
351-
// raise an error. We don't care about it.
352-
Runtime.PyErr_Clear();
353356

354357
cache.Clear();
355358
}

0 commit comments

Comments
 (0)