Message273242
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. |
|
Date |
User |
Action |
Args |
2016-08-20 19:18:23 | ncoghlan | set | recipients:
+ ncoghlan, barry, rhettinger, SilentGhost, yselivanov, mb_ |
2016-08-20 19:18:23 | ncoghlan | set | messageid: <1471720703.55.0.995759162337.issue27814@psf.upfronthosting.co.za> |
2016-08-20 19:18:23 | ncoghlan | link | issue27814 messages |
2016-08-20 19:18:22 | ncoghlan | create | |
|