(original) (raw)



On Fri, Mar 2, 2012 at 05:22, Nick Coghlan <ncoghlan@gmail.com> wrote:

On Fri, Mar 2, 2012 at 10:55 PM, Stefan Krah <stefan@bytereef.org> wrote:
> Nick Coghlan <ncoghlan@gmail.com> wrote:
>> However, given the lack of control, an assert() isn't the appropriate
>> tool here - PyObject\_GetBuffer itself should be \*checking\* the
>> constraint and then reporting an error if the check fails. Otherwise a
>> misbehaving extension module could trivially crash the Python
>> interpreter by returning a bad Py\_buffer.
>
> I'm not so sure. Extension modules that use the C-API in wrong or
> undocumented ways can always crash the interpreter. This assert()
> should be triggered in the first unit test of the module. Now, if
> the module does not have unit tests or they don't test against a
> new Python version is that really our problem?

Crashing out with a C assert when we can easily give them a nice
Python traceback instead is unnecessarily unfriendly.

But you should keep in mind that for non-debug builds, asserts are generally off. So the behaviour most people see isn't actually a crash, but silent acceptance.

--
Thomas Wouters <thomas@python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!