diff options
author | Dong-hee Na <donghee.na@python.org> | 2021-10-09 15:16:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-09 15:16:12 (GMT) |
commit | ec04db74e24a5f5da441bcabbe259157b4938b9b (patch) | |
tree | 144ac36d272a7b0daaa3c33c1976ec5119f9e182 /Modules/_csv.c | |
parent | 34bbc87b2ddbaf245fbed6443c3e620f80c6a843 (diff) | |
download | cpython-ec04db74e24a5f5da441bcabbe259157b4938b9b.zip cpython-ec04db74e24a5f5da441bcabbe259157b4938b9b.tar.gz cpython-ec04db74e24a5f5da441bcabbe259157b4938b9b.tar.bz2 |
bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832)
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r-- | Modules/_csv.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index cfdfbce..72f0791 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -244,6 +244,9 @@ _set_char_or_none(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt return -1; } Py_ssize_t len = PyUnicode_GetLength(src); + if (len < 0) { + return -1; + } if (len > 1) { PyErr_Format(PyExc_TypeError, "\"%s\" must be a 1-character string", @@ -274,6 +277,9 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt) return -1; } Py_ssize_t len = PyUnicode_GetLength(src); + if (len < 0) { + return -1; + } if (len > 1) { PyErr_Format(PyExc_TypeError, "\"%s\" must be a 1-character string", |