diff options
author | Guido van Rossum <guido@python.org> | 2007-05-09 23:36:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-09 23:36:14 (GMT) |
commit | 63eac1592700e550d7a8e9b5ef1f77cadac9a020 (patch) | |
tree | cb49290607519554517e183ed1a2ab45fc69a971 /Objects/bytesobject.c | |
parent | d70539abef79c2ae4ab0c0319a1ee47c10f048dc (diff) | |
download | cpython-63eac1592700e550d7a8e9b5ef1f77cadac9a020.zip cpython-63eac1592700e550d7a8e9b5ef1f77cadac9a020.tar.gz cpython-63eac1592700e550d7a8e9b5ef1f77cadac9a020.tar.bz2 |
The NULL pointer for empty strings turns out to be a pain.
At least for the buffer API, return "" in that case.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index a07f9e7..2cdaf37 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -950,7 +950,10 @@ bytes_getbuffer(PyBytesObject *self, Py_ssize_t index, const void **ptr) "accessing non-existent bytes segment"); return -1; } - *ptr = (void *)self->ob_bytes; + if (self->ob_bytes == NULL) + *ptr = ""; + else + *ptr = self->ob_bytes; return self->ob_size; } |