diff --git a/src/public/py_mappingproxy.c b/src/public/py_mappingproxy.c index 506619e2..85d9f2c1 100644 --- a/src/public/py_mappingproxy.c +++ b/src/public/py_mappingproxy.c @@ -63,6 +63,15 @@ static bool namedict_items(int argc, py_Ref argv) { return true; } +static bool namedict_clear(int argc, py_Ref argv) { + PY_CHECK_ARGC(1); + py_Ref object = py_getslot(argv, 0); + NameDict* dict = PyObject__dict(object->_obj); + NameDict__clear(dict); + py_newnone(py_retval()); + return true; +} + py_Type pk_namedict__register() { py_Type type = pk_newtype("namedict", tp_object, NULL, NULL, false, true); @@ -72,6 +81,7 @@ py_Type pk_namedict__register() { py_bindmagic(type, __contains__, namedict__contains__); py_newnone(py_tpgetmagic(type, __hash__)); py_bindmethod(type, "items", namedict_items); + py_bindmethod(type, "clear", namedict_clear); return type; }