Issue #17223: array module: Fix a crasher when converting an array containing
invalid characters (outside range [U+0000; U+10ffff]) to Unicode: repr(array),
str(array) and array.tounicode(). Patch written by Manuel Jacob.
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index adc4d5d..96c9e5b 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -2180,6 +2180,8 @@
} else {
v = array_tolist(a, NULL);
}
+ if (v == NULL)
+ return NULL;
s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v);
Py_DECREF(v);