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

Nick Coghlan report at bugs.python.org
Thu Sep 29 23:07:42 EDT 2016


Nick Coghlan added the comment:

Due to the expected semantics of AttributeError being relatively precise, changing to a protocol check rather than just changing the order we look up the protocol attributes would also involving changing from AttributeError to TypeError.

Since that's a potentially more disruptive change and just changing the order of the checks is likely sufficient to reduce confusion, the latter approach is preferable, at least for now (if folks are still getting confused by the time 3.7 rolls around, then that option would be worth reconsidering).

----------

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


More information about the Python-bugs-list mailing list