Make the StringIO test pass.

The buffer object now special-cases Unicode when concatenating.  Sigh.
This commit is contained in:
Guido van Rossum 2007-05-08 23:08:31 +00:00
parent cfe5f20fe8
commit bc14efbd08
2 changed files with 36 additions and 23 deletions

View file

@ -424,15 +424,24 @@ buffer_concat(PyBufferObject *self, PyObject *other)
return NULL;
/* optimize special case */
/* XXX bad idea type-wise */
if ( size == 0 )
{
Py_INCREF(other);
return other;
}
if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
return NULL;
if (PyUnicode_Check(other)) {
/* XXX HACK */
if ( (count = (*pb->bf_getcharbuffer)(other, 0, &ptr2)) < 0 )
return NULL;
}
else {
if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
return NULL;
}
/* XXX Should return a bytes object, really */
ob = PyString_FromStringAndSize(NULL, size + count);
if ( ob == NULL )
return NULL;