[Python-Dev] PEP 296 - The Buffer Problem
Tim Peters
tim.one@comcast.net
Thu, 25 Jul 2002 15:51:44 -0400
[Scott Gilbert]
> ...
> How would you designate failure/exceptions? size_t is unsigned everywhere
> I can find it,
Right, and the std requires that size_t resolve to an unsigned type, so
that's reliable.
> so it can't return a negative number on failure.
The usual dodge is to return (and test against)
(size_t)-1
in that case. If the caller sees that the result is (size_t)-1, then it
also needs to call PyErr_Occurred() to see whether it's a normal, or error,
return value (and if it is an error case, the routine had to have set a
Python exception, so that PyErr_Occurred() returns true then).
> I guess the void** could be filled in with NULL.
Sounds easier to me <wink>.