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.

Author benrg
Recipients benrg, theller
Date 2011-03-07.07:11:24
SpamBayes Score 4.901427e-10
Marked as misclassified No
Message-id <1299481885.21.0.0627562040827.issue11427@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 3.1.3, (c_char*5).from_buffer(b'abcde') worked. In 3.2 it fails with "TypeError: expected an object with a writable buffer interface".

This seems to represent a significant decrease in the functionality of ctypes, since, if I understand correctly, it has no notion of a const array or a const char. I used from_buffer with a bytes argument in 3.1 and it was far from obvious how to port to 3.2 without introducing expensive copying. I understand the motivation behind requiring a writable buffer, but I think it's a bad idea. If you take this to its logical conclusion, it should not be possible to pass bytes or str values directly to C functions, since there's no way to be sure they won't write through the pointer.
History
Date User Action Args
2011-03-07 07:11:25benrgsetrecipients: + benrg, theller
2011-03-07 07:11:25benrgsetmessageid: <1299481885.21.0.0627562040827.issue11427@psf.upfronthosting.co.za>
2011-03-07 07:11:24benrglinkissue11427 messages
2011-03-07 07:11:24benrgcreate