mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
bpo-29116: Improve error message for concatenating str with non-str. (#710)
This commit is contained in:
parent
80ec8364f1
commit
004e03fb0c
1 changed files with 10 additions and 1 deletions
|
@ -11282,7 +11282,16 @@ PyUnicode_Concat(PyObject *left, PyObject *right)
|
||||||
Py_UCS4 maxchar, maxchar2;
|
Py_UCS4 maxchar, maxchar2;
|
||||||
Py_ssize_t left_len, right_len, new_len;
|
Py_ssize_t left_len, right_len, new_len;
|
||||||
|
|
||||||
if (ensure_unicode(left) < 0 || ensure_unicode(right) < 0)
|
if (ensure_unicode(left) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!PyUnicode_Check(right)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"can only concatenate str (not \"%.200s\") to str",
|
||||||
|
right->ob_type->tp_name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (PyUnicode_READY(right) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Shortcuts */
|
/* Shortcuts */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue