Skip to content

Commit

Permalink
bpo-29116: Improve error message for concatenating str with non-str. (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored Mar 19, 2017
1 parent 80ec836 commit 004e03f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -11282,7 +11282,16 @@ PyUnicode_Concat(PyObject *left, PyObject *right)
Py_UCS4 maxchar, maxchar2;
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;

/* Shortcuts */
Expand Down

0 comments on commit 004e03f

Please sign in to comment.