New submission from Daniel Holth <[email protected]>:
The io documentation says:
IOBase is also a context manager and therefore supports the with statement. In
this example, file is closed after the with statement’s suite is finished—even
if an exception occurs:
with open('spam.txt', 'w') as file:
file.write('Spam and eggs!')
I read this to mean that my own subclass of io.BufferedIOBase would call
close() when used as a context manager.
Instead, it is necessary to provide an implementation of __exit__ that calls
close() to get this behavior.
The documentation lists Mixin Methods, but I couldn't find a definition of the
term "Mixin Methods" in the docs.
----------
components: IO
messages: 366032
nosy: dholth
priority: normal
severity: normal
status: open
title: confusing documentation for IOBase.__exit__
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40235>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com