Mercurial > cpython-lru_cache-weakref
diff Objects/bufferobject.c @ 41652:050c98cd41c4
Make the StringIO test pass.
The buffer object now special-cases Unicode when concatenating. Sigh.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 08 May 2007 23:08:31 +0000 |
| parents | 13d5e5f0e993 |
| children | c9c52b87c30b |
line wrap: on
line diff
--- a/Objects/bufferobject.c Tue May 08 21:26:54 2007 +0000 +++ b/Objects/bufferobject.c Tue May 08 23:08:31 2007 +0000 @@ -424,15 +424,24 @@ 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;
