Issue #21897: Fix a crash with the f_locals attribute with closure variables when frame.clear() has been called.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 0d62293..55ee563 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -786,7 +786,7 @@
         PyObject *key = PyTuple_GET_ITEM(map, j);
         PyObject *value = values[j];
         assert(PyUnicode_Check(key));
-        if (deref) {
+        if (deref && value != NULL) {
             assert(PyCell_Check(value));
             value = PyCell_GET(value);
         }