mirror of
https://github.com/python/cpython
synced 2026-09-29 09:05:29 +03:00
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:
parent
d70539abef
commit
63eac15927
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue