mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Make the StringIO test pass.
The buffer object now special-cases Unicode when concatenating. Sigh.
This commit is contained in:
parent
cfe5f20fe8
commit
bc14efbd08
2 changed files with 36 additions and 23 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue