Vlad Riscutia <riscutiav...@gmail.com> added the comment:

The main reason for this issue is that internally ctypes doesn't consider 
c_char_p as a pointer type. This is a bit counter-intuitive, but c_char_p is 
treated as a simple type and has some other sugar built-in, like easier 
integration with Python strings. Alternative pointer type is POINTER(c_char), 
which allows assignment from array.

I would make this clear in the documentation. Even now, documentation says 
following about c_char_p:

Represents the C char * datatype when it points to a zero-terminated string. 
For a general character pointer that may also point to binary data, 
POINTER(c_char) must be used. The constructor accepts an integer address, or a 
string.

So there already is a hint that c_char_p has limited use for convenience. We 
should maybe make documentation more clear. If you want equivalent of C char* 
behavior, POINTER(c_char) is the way to go.

----------
nosy: +vladris

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5149>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to