diff options
author | Dong-hee Na <donghee.na@python.org> | 2021-10-10 01:13:44 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 01:13:44 +0900 |
commit | e4fcb6fd3dcc4db23867c2fbd538189b8f221225 (patch) | |
tree | d6ef7e6f9d6915f800a4faaa9e5a6588cf780c28 /Modules | |
parent | 6f3bc5eee6729197747d324c167da12902fb7c27 (diff) | |
download | cpython-git-e4fcb6fd3dcc4db23867c2fbd538189b8f221225.tar.gz |
[3.9] bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832) (GH-28835)
Diffstat (limited to 'Modules')
-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 40a6361d20..029f473ae8 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -246,6 +246,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", @@ -276,6 +279,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", |