Author jaraco
Recipients jaraco
Date 2018-03-26.16:40:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I propose the following expansion of the interface of contextlib.suppress. Currently, when entering the context, suppress returns None. Instead, it could return an object that provides some detail about the exception.

Inspiration for an implementation exists in pytest (, capturing the commonly-encountered use-cases, where one wishes to capture, suppress, and then act on a subset of exceptions, allowing others to raise normally.

In [py-181](, I suggest exposing this functionality generally, but others had an instinct similar to mine - that perhaps the stdlib should be providing this interface.

In addition to saving the exception for inspection, the pytest implementation also allows a "message" to be supplied (for those exceptions where only some subset of the class of Exception is suppressed).

I present this concept here for consideration and feedback. Can contextlib.suppress be expanded with such an interface?
Date User Action Args
2018-03-26 16:40:34jaracosetrecipients: + jaraco
2018-03-26 16:40:34jaracosetmessageid: <>
2018-03-26 16:40:34jaracolinkissue33146 messages
2018-03-26 16:40:33jaracocreate