Thomas Wouters added the comment:

What happens when you don't have the assert depends on whether the new function 
call raises an exception or not, and keep in mind *this is what most people see 
anyway*: if the new call does not raise an exception, a SystemError is raised, 
with the original exception as cause:

Traceback (most recent call last):
  File "<stdin>", line 5, in func
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: PyEval_EvalFrameEx returned a result with an error set

If the new call does raise an exception, the original exception is lost 
(although this may depend on the exact path through the code here; there's 
quite a few places that deal with this kind of thing.)

I don't mind dropping the assert changes from my PR, but I don't really 
understand why it is better to be *less* helpful when asserts are enabled :) As 
I said, the actual assert failure does very little to point to the real 
problem, as the problem is *some* extension module not clearing the error (or 
not returning an error value), and the assert does not guard against actual 
problems -- nothing goes "more wrong" when the assert is not there. I would 
also argue that an extension module is not *internal* to CPython, any more than 
arguments passed to a builtin function are.

----------

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

Reply via email to