mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832)
This commit is contained in:
parent
34bbc87b2d
commit
ec04db74e2
1 changed files with 6 additions and 0 deletions
|
@ -244,6 +244,9 @@ _set_char_or_none(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_ssize_t len = PyUnicode_GetLength(src);
|
Py_ssize_t len = PyUnicode_GetLength(src);
|
||||||
|
if (len < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"\"%s\" must be a 1-character string",
|
"\"%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;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_ssize_t len = PyUnicode_GetLength(src);
|
Py_ssize_t len = PyUnicode_GetLength(src);
|
||||||
|
if (len < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"\"%s\" must be a 1-character string",
|
"\"%s\" must be a 1-character string",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue