summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2021-10-09 16:13:21 (GMT)
committerGitHub <noreply@github.com>2021-10-09 16:13:21 (GMT)
commitc80f0b7aa1d90332d0069d3e85ee112d0c9da7f0 (patch)
tree2ec83c9ba1f67eb69be3046aa3895ae4c0ee7fcf /Modules
parent8772935765e7a4f04f7f561e37d0c0aee71d8030 (diff)
downloadcpython-c80f0b7aa1d90332d0069d3e85ee112d0c9da7f0.zip
cpython-c80f0b7aa1d90332d0069d3e85ee112d0c9da7f0.tar.gz
cpython-c80f0b7aa1d90332d0069d3e85ee112d0c9da7f0.tar.bz2
[3.10] bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832) (GH-28834)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_csv.c6
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",