This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients SilentGhost, barry, mb_, ncoghlan, rhettinger, yselivanov
Date 2016-08-20.19:18:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471720703.55.0.995759162337.issue27814@psf.upfronthosting.co.za>
In-reply-to
Content
contextlib.suppress provides a contextmanager spelling for the following pattern:

    try:
        <body>
    except <expr>:
        pass

That's a very common pattern worth having in the standard library, even though it's only a 5 line context manager.

The proposed API change would make it instead an implementation of the vastly *less* common pattern:

    try:
        <body>
    except <unless-expr>:
        raise
    except <expr>:
        pass

For the use case you're discussing (trying to shut down, potentially failing, but also not wanting to hide genuine programming errors), I'd be more amenable to introducing a comparable context manager to the logging module that, instead of silently ignoring caught exceptions, logged them, and also allowed you to restrict which exceptions were logged.
History
Date User Action Args
2016-08-20 19:18:23ncoghlansetrecipients: + ncoghlan, barry, rhettinger, SilentGhost, yselivanov, mb_
2016-08-20 19:18:23ncoghlansetmessageid: <1471720703.55.0.995759162337.issue27814@psf.upfronthosting.co.za>
2016-08-20 19:18:23ncoghlanlinkissue27814 messages
2016-08-20 19:18:22ncoghlancreate