Skip to content

Commit e4fcb6f

Browse files
authored
[3.9] bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832) (GH-28835)
1 parent 6f3bc5e commit e4fcb6f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Modules/_csv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ _set_char_or_none(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt
246246
return -1;
247247
}
248248
Py_ssize_t len = PyUnicode_GetLength(src);
249+
if (len < 0) {
250+
return -1;
251+
}
249252
if (len > 1) {
250253
PyErr_Format(PyExc_TypeError,
251254
"\"%s\" must be a 1-character string",
@@ -276,6 +279,9 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt)
276279
return -1;
277280
}
278281
Py_ssize_t len = PyUnicode_GetLength(src);
282+
if (len < 0) {
283+
return -1;
284+
}
279285
if (len > 1) {
280286
PyErr_Format(PyExc_TypeError,
281287
"\"%s\" must be a 1-character string",

0 commit comments

Comments
 (0)