[Python-checkins] [3.10] bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832) (GH-28834)
corona10
webhook-mailer at python.org
Sat Oct 9 12:13:25 EDT 2021
https://github.com/python/cpython/commit/c80f0b7aa1d90332d0069d3e85ee112d0c9da7f0
commit: c80f0b7aa1d90332d0069d3e85ee112d0c9da7f0
branch: 3.10
author: Dong-hee Na <donghee.na at python.org>
committer: corona10 <donghee.na92 at gmail.com>
date: 2021-10-10T01:13:21+09:00
summary:
[3.10] bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832) (GH-28834)
files:
M Modules/_csv.c
diff --git a/Modules/_csv.c b/Modules/_csv.c
index cfdfbce6e6824..72f0791a4398b 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",
More information about the Python-checkins
mailing list