Issue #16856: Fix a segmentation fault from calling repr() on a dict with
a key whose repr raise an exception.
diff --git a/Misc/NEWS b/Misc/NEWS
index 310a0b2..e638039 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #16856: Fix a segmentation fault from calling repr() on a dict with
+  a key whose repr raise an exception.
+
 - Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
 
 - Issue #16761: Calling int() with base argument only now raises TypeError.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 88010e6..c9185bd 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -10548,7 +10548,7 @@
         return;
     }
     left = *p_left;
-    if (right == NULL || !PyUnicode_Check(left)) {
+    if (right == NULL || left == NULL || !PyUnicode_Check(left)) {
         if (!PyErr_Occurred())
             PyErr_BadInternalCall();
         goto error;