diff options
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5dd89c4..c5acd1b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1076,7 +1076,13 @@ PyObject *PyUnicode_FromEncodedObject(register PyObject *obj, if (PyString_Check(obj)) { s = PyString_AS_STRING(obj); len = PyString_GET_SIZE(obj); - } + } + else if (PyBytes_Check(obj)) { + /* Python 2.x specific */ + PyErr_Format(PyExc_TypeError, + "decoding bytearray is not supported"); + return NULL; + } else if (PyObject_AsCharBuffer(obj, &s, &len)) { /* Overwrite the error message with something more useful in case of a TypeError. */ |