diff -r 82ae284cd5f1 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Mon Sep 03 17:29:22 2012 -0400 +++ b/Objects/unicodeobject.c Tue Sep 04 16:09:09 2012 +1000 @@ -7322,6 +7322,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);