[issue23571] Raise SystemError if a function returns a result with an exception set

STINNER Victor report at bugs.python.org
Fri Mar 6 23:22:22 CET 2015


STINNER Victor added the comment:

2015-03-06 16:55 GMT+01:00 Serhiy Storchaka <report at bugs.python.org>:
> We can ignore such little slow down (if this is not just compiler artifact).

Maybe it's time to play with micro-optimizations like __builtin_expect
:-) But I would prefer to do that in a separated issue. The patch is
already long and complex.

> The patch LGTM. I afraid there will be issues with third-party code that will need an adaptation to 3.5, but on other hand, this patch could help with catching some hidden bugs.

My patch doesn't make more strict. Without my patch, if a function
returns a result and raise an exception, the exception will still be
noticed, but probably later. The purpose of my change is to notify
immediatly that the function raised an exception.

Without my patch, if a function returns a result and raise an
exception, it's possible that the exception is cleared and so never
seen.

In older Python versions, Python/ceval.c displayed the message "XXX
undetected error" when an exception was raised but also a result was
returned.

Anyway, you must fix your code :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23571>
_______________________________________


More information about the Python-bugs-list mailing list