diff -r d9a3d23cf8f0 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Tue Oct 14 00:53:13 2014 +0200 +++ b/Objects/unicodeobject.c Tue Oct 14 15:10:15 2014 +0200 @@ -7463,6 +7463,11 @@ Py_ssize_t offset; int chunk_len, ret, done; + if (!PyUnicode_Check(unicode)) { + PyErr_BadArgument(); + return NULL; + } + if (PyUnicode_READY(unicode) == -1) return NULL; len = PyUnicode_GET_LENGTH(unicode);