[Python-3000] PyBUF_LOCK fails on bytes objects. they're read-only, why should it fail?
Travis Oliphant
oliphant.travis at ieee.org
Sat Mar 15 06:46:58 CET 2008
Gregory P. Smith wrote:
> bytes objects are by their definition immutable and read only. but when
> passing one to a buffer api that tries to use the PyBUF_LOCK flag it
> raises BufferError "Cannot lock this object." from PyBuffer_FillInfo in
> Objects/abstract.c as called by Objects/bytesobject.c's bytes_getbuffer
> method.
>
> I think the problem is a >= 0 where a != 0 was intended in
> PyBuffer_FillInfo:
>
> --- Objects/abstract.c (revision 61375)
> +++ Objects/abstract.c (working copy)
> @@ -673,7 +673,7 @@
> {
> if (view == NULL) return 0;
> if (((flags & PyBUF_LOCK) == PyBUF_LOCK) &&
> - readonly >= 0) {
> + readonly != 0) {
> PyErr_SetString(PyExc_BufferError,
> "Cannot lock this object.");
> return -1;
>
>
Good catch. This looks like a good fix.
-Travis O.
More information about the Python-3000
mailing list