New submission from Daniel Holth dho...@fastmail.fm:
How much do we care about special method lookup? Python recently bypasses
__getattr__ entirely when looking up context managers.
http://mail.python.org/pipermail/python-dev/2009-May/089535.html
Could this be the reason that ZODB's transaction module, which attempts to be a
context manager by declaring
manager = ThreadTransactionManager()
__enter__ = manager.get
__exit__ = manager.__exit__
Does not work in Python 2.7.1 on Ubuntu 11.04 or RHEL5? Frustratingly, the
exception is no more specific than an AttributeError, even though
hasattr(transaction, '__exit__')?
I would prefer to never get AttributeError: transaction.__exit__ when
hasattr(transaction, '__exit__') as I find that to be very confusing. Maybe the
interpreter could raise SpecialAttributeError('transaction.__exit__ is not
sufficiently special') instead.
http://svn.zope.org/repos/main/transaction/trunk/transaction/__init__.py
--
components: Interpreter Core
messages: 135365
nosy: dholth
priority: normal
severity: normal
status: open
title: 'transaction' module-as-context-manager thwarted by Python 2.7.1
type: behavior
versions: Python 2.7
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12022
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com