summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-09 23:36:14 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-09 23:36:14 (GMT)
commit63eac1592700e550d7a8e9b5ef1f77cadac9a020 (patch)
treecb49290607519554517e183ed1a2ab45fc69a971
parentd70539abef79c2ae4ab0c0319a1ee47c10f048dc (diff)
downloadcpython-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.
-rw-r--r--Objects/bytesobject.c5
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;
}