Issue 10001: ~Py_buffer.obj field is undocumented, though not hidden (original) (raw)

Created on 2010-09-30 17:46 by kermode, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bufobj.c.gz kermode,2010-09-30 17:46 Embedded Python C program; crashes with Python 3.2a2
Messages (4)
msg117754 - (view) Author: Lenard Lindstrom (kermode) Date: 2010-09-30 17:46
Python 3.2a2+ (py3k:85072M, Sep 29 2010, 12:11:17) (from SVN) [GCC 4.4.5 20100728 (prerelease)] on linux2 (Debian squeeze) The ~Py_buffer.obj field is undocumented. Yet memoryview, that acts as a wrapper, includes the field in gc traversal. Also, if the field is not initialized by bf_getbuffer its value can be indeterminate. For memoryview the gc can crash (see attached C demo program).
msg117770 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-01 01:10
The recommended way is to use PyBuffer_FillInfo() (and then fill in any additional data if necessary), which will set the pointer and incref it itself. I agree all this is a bit poorly documented.
msg117780 - (view) Author: Lenard Lindstrom (kermode) Date: 2010-10-01 07:26
This will work for bf_getbuffer, though having PyObject_GetBuffer set the obj field before passing it to the callback might be safer. Also, this does not address the case with wrapper types like memoryview. What happens if ~Py_buffer.obj is not visited in tp_traverse? Should this be documented?
msg125330 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2011-01-04 14:56
Closing as a dupe of 10181, but transferring Lenard's comments over there.
History
Date User Action Args
2022-04-11 14:57:07 admin set github: 54210
2011-01-04 14:56:10 ncoghlan set status: open -> closedsuperseder: Problems with Py_buffer management in memoryobject.c (and elsewhere?)messages: + nosy:mark.dickinson, ncoghlan, kermode, pitrou, docs@pythonresolution: duplicate
2011-01-04 01:03:42 pitrou set nosy: + mark.dickinson, ncoghlan
2010-10-01 07:26:12 kermode set messages: +
2010-10-01 01:10:22 pitrou set assignee: docs@pythoncomponents: + Documentation, - Interpreter Coreversions: + Python 3.1, Python 2.7nosy: + docs@python, pitroumessages: + stage: needs patch
2010-09-30 17:46:45 kermode create