[issue3139] bytearrays are not thread safe

Antoine Pitrou report at bugs.python.org
Wed Aug 13 20:07:36 CEST 2008


Antoine Pitrou <pitrou at free.fr> added the comment:

Le mardi 12 août 2008 à 16:15 +0000, Martin v. Löwis a écrit :
> I also started working on porting it to 3.0, but couldn't complete that
> port yet - the memoryview object doesn't play nicely.

I've seen your recent merge and I don't know if you have finished with
it.

I think we should drop the "base" member in PyMemoryViewObject, it has
become redundant and confusing. There are some places in memoryobject.c
where base seems mistakingly used instead of view.obj, e.g.
PyMemoryView_FromMemory INCREFs view.obj, but memory_dealloc DECREFs
base.
Also, I don't understand why memory_getbuf INCREFs view.obj, there is no
corresponding DECREF in memory_releasebuf and view.obj should already
have been INCREFed anyway.

(if people want to get easily at the base object, we could provide be a
macro e.g. PyMemory_GET_BASE())

By the way, perhaps PyBuffer_Release should set view->obj and view->buf
to NULL (and view->len to -1?), it would be a simple way to signal that
the buffer can't be used anymore.

What do you think?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3139>
_______________________________________


More information about the Python-bugs-list mailing list