summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-19 17:38:42 (GMT)
committerGitHub <noreply@github.com>2017-03-19 17:38:42 (GMT)
commit004e03fb0c2febe2ec8afbd28ffcb3e980c63228 (patch)
treea4ab65311eb8398b28288af68f4a31b44e8746ad /Objects
parent80ec8364f15857c405ef0ecb1e758c8fc6b332f7 (diff)
downloadcpython-004e03fb0c2febe2ec8afbd28ffcb3e980c63228.zip
cpython-004e03fb0c2febe2ec8afbd28ffcb3e980c63228.tar.gz
cpython-004e03fb0c2febe2ec8afbd28ffcb3e980c63228.tar.bz2
bpo-29116: Improve error message for concatenating str with non-str. (#710)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 503a59e..1a696cc 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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 */