[issue24474] Accidental exception chaining in inspect.Signature.bind()

Nick Coghlan report at bugs.python.org
Sat Jun 20 08:28:35 CEST 2015


Nick Coghlan added the comment:

This isn't a bug, as "raise exc from None" only hides *display* of the context, it doesn't lose the record of the context entirely.

This means Walter's display code is incorrect, as it isn't checking for __suppress_context__:

>>> import inspect
>>> try:
...     inspect.signature(lambda x:None).bind()
... except Exception as e:
...     exc = e
... 
>>> exc.__suppress_context__
True

Interestingly, neither PEP 409 *nor* PEP 415 capture the rationale for that design: retaining the full context data even when it's hidden by the default exception display routines means that you can still debug code that uses "raise X from None" inappropriately. (I thought there was an open RFE to make it easy to force the traceback module to ignore __suppress_context__ but if there is one, I can't find it)

----------
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list