Nick Coghlan <ncogh...@gmail.com> wrote: > On Tue, Mar 6, 2012 at 8:34 PM, Stefan Krah <ste...@bytereef.org> wrote: > > The obvious question is: Will anyone need view==NULL in the future or > > can we remove the special case? > > The public API will still need a guard (to report an error), but +1 > for otherwise eliminating the undocumented special case.
I'm looking at other getbufferprocs apart from bytearray_getbuffer() and the public API seems pretty dangerous to me: For example, bytes_buffer_getbuffer() just calls PyBuffer_FillInfo(), which instantly returns 0 (success). Now the reference count to the bytes object is *not* incremented, so it might disappear while the consumer still thinks it's valid. The same happens in _ctypes.c:PyCData_NewGetBuffer(). For array_buffer_getbuf() it looks different: The export count is increased, but not the reference count. So while the array is protected against resizing, it's not immediately obvious to me if it's protected against being deallocated (but I just skimmed the code). It seems to me that bytearray was the only place where the view==NULL scheme obviously worked. Stefan Krah _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com