diff --git a/Modules/_csv.c b/Modules/_csv.c index aea071cc143328..0b7ff2575fcfec 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -302,8 +302,12 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt) static int _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt) { - if (src == NULL) + if (src == NULL) { *target = PyUnicode_DecodeASCII(dflt, strlen(dflt), NULL); + if (*target == NULL) { + return -1; + } + } else { if (src == Py_None) *target = NULL;