[issue2123] ctypes pointer not always keeping target alive
Thomas Heller
report at bugs.python.org
Fri Feb 15 21:00:13 CET 2008
Thomas Heller added the comment:
May I ask: do you have a real use case for this, or is it a carefully
constructed example?
Of course I take all the blame for not defining/documenting this
stuff. My current view is this:
Python code C code
======================= ================
ptr = POINTER(c_long)() int *ptr = NULL;
x = c_long(42) int x = 42;
ptr.contents = x ptr = &x;
a = ptr[0] int a = *ptr;
b = ptr[n] int b = ptr[n];
Assigning to .contents changes 'where the pointer points to'.
__setitem__ changes the pointed to memory location; __getitem__
retrieves the pointed to memory location.
Having said that, it is no longer clear to me what reading the
.contents attribute should mean. Would making the .contents attribute
write-only help - is it impossible to construct this 'bug' without
assigning to .contents?
----------
assignee: -> theller
nosy: +theller
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2123>
__________________________________
More information about the Python-bugs-list
mailing list