The NULL pointer for empty strings turns out to be a pain.

At least for the buffer API, return "" in that case.
This commit is contained in:
Guido van Rossum 2007-05-09 23:36:14 +00:00
parent d70539abef
commit 63eac15927
1 changed files with 4 additions and 1 deletions

View File

@ -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;
}