13.07.19 23:25, Kyle Stanley пише:
Serhiy Storchaka wrote:
Are your aware of contextlib.nested()? And why it was deprecated and
removed?
Was contextlib.nested() removed primarily due to to the inconsistencies
mentioned in https://bugs.python.org/issue5251 or was it something else?
Yes, it was removed because of the inherent flaw of such design. In
`with nested(open('a'), open('b'))` if the second open failed, the first
file will be leaked. No nested() object even be created, so this can't
be fixed in it. There is exactly the same problem with using a tuple as
a context manager.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/PRM3NLT37DWFNPNIILOEFA4PZEETWQBS/
Code of Conduct: http://python.org/psf/codeofconduct/