What should happen if the context manager attempts to suppress a raised exception? In cases where you applied the context manager to an entire line, e.g.
data = fail() with contextlib.suppress(Exception)
Then it would make sense to treat it like
data = fail()
Where `data` remains unassigned after the block executes assuming `fail` raises an exception. However, with the initial proposal you run into trouble when you apply this to sub-expressions that are expected to themselves have a value. For example, what should happen here?
more_work(fail() with contextlib.suppress(Exception))
We have no value to pass as an argument to `more_work` so there's no way we can call it. Yet it would be odd to not call it if there's no exception being raised since it exists outside of any context manager itself.
Python-ideas mailing list -- email@example.com
To unsubscribe send an email to firstname.lastname@example.org
Message archived at https://email@example.com/message/Y7WZDD2AFGUX3ND2OX3EUN2VUK27O4E5/
Code of Conduct: http://python.org/psf/codeofconduct/