[issue46819] Add an Error / Exception / Warning when contextlib.suppress() is entered with no specified exception(s) to suppress

Serhiy Storchaka report at bugs.python.org
Tue Feb 22 13:27:02 EST 2022


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

No, I say that

    with suppress():
        ...

is equivalent to

    try:
        ...
    except ():
        pass

or

    try:
        ...
    except BaseException as err:
        if not isinstance(err, ()):
            raise

If you want to suppress all exceptions (it is not very clever idea), use suppress(BaseException).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46819>
_______________________________________


More information about the Python-bugs-list mailing list