[issue27100] Attempting to use class with both __enter__ & __exit__ undefined yields __exit__ attribute error

Raymond Hettinger report at bugs.python.org
Tue May 24 01:28:48 EDT 2016


Raymond Hettinger added the comment:

Nick, I've seen the come-up several times with people learning about context managers.  The current error message seems cause confusion because it checks for __exit__ before __enter__, implying that the __enter__ is optional which it isn't.   Do you have any objections testing for __enter__ first?

----------
assignee:  -> rhettinger
nosy: +ncoghlan
versions: +Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27100>
_______________________________________


More information about the Python-bugs-list mailing list