From 63eac1592700e550d7a8e9b5ef1f77cadac9a020 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 9 May 2007 23:36:14 +0000 Subject: The NULL pointer for empty strings turns out to be a pain. At least for the buffer API, return "" in that case. --- Objects/bytesobject.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- cgit v0.12