Jack Jansen wrote:
[on the user-supplies-buffer interface] I think this would be much less error-prone than having fixed-length buffers all over the place.
PyArg_ParseTuple() should probably raise an error in case the data doesn't fit into the buffer.
Ah, that's right, that solves most of that problem.
[on the malloced interface] Good point. You'll still need the buffer_len output parameter though -- otherwise you wouldn't be able tell the size of the allocated buffer (the returned data may not be terminated).
Are you sure? I would expect the "eS" format to be used to obtain 8-bit data in some local encoding, and I would expect that all 8-bit encodings of unicode data would still allow for null-termination. Or are there 8-bit encodings out there where a zero byte is normal occurrence and where it can't be used as terminator?
Not sure whether these exist or not, but they are certainly a possibility to keep in mind. Perhaps adding "es#" and "es" (with 0-byte check) would be ideal ?! -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/