[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

Éric Araujo report at bugs.python.org
Mon May 23 16:09:45 CEST 2011


Éric Araujo <merwok at netwok.org> added the comment:

> hasattr(transaction, '__exit__')

http://docs.python.org/dev/reference/datamodel#special-method-names explains that magic methods are looked up on the class, not on the instances.  There’s a lot of code out there that erroneously checks for __len__ or __call__ on instances, and this is the second time to my knowledge that a project abused a module-level __enter__ function.

----------
nosy: +eric.araujo

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


More information about the Python-bugs-list mailing list