This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: ~Py_buffer.obj field is undocumented, though not hidden
类型: Stage: needs patch
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7
process
状态: closed Resolution: duplicate
Dependencies: 后续: Problems with Py_buffer management in memoryobject.c (and elsewhere?)
View: 10181
分配给: docs@python 抄送列表: docs@python, kermode, mark.dickinson, ncoghlan, pitrou
优先级: normal 关键字:

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

文件
文件名 上传时间 Description 编辑
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) 日期: 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) 日期: 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) 日期: 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) 日期: 2011-01-04 14:56
Closing as a dupe of 10181, but transferring Lenard's comments over there.
历史
日期 用户 动作 参数
2022-04-11 14:57:07admin修改github: 54210
2011-01-04 14:56:10ncoghlan修改状态: open -> closed
后续: Problems with Py_buffer management in memoryobject.c (and elsewhere?)
消息: + msg125330

抄送: mark.dickinson, ncoghlan, kermode, pitrou, docs@python
resolution: duplicate
2011-01-04 01:03:42pitrou修改抄送: + mark.dickinson, ncoghlan
2010-10-01 07:26:12kermode修改消息: + msg117780
2010-10-01 01:10:22pitrou修改assignee: docs@python
components: + Documentation, - Interpreter Core
versions: + Python 3.1, Python 2.7
抄送: + docs@python, pitrou

消息: + msg117770
stage: needs patch
2010-09-30 17:46:45kermode创建