Message182598
We have implemented the context manager API for connections and cursors in our mxODBC module and this works fine in Python 2.6.
In Python 2.7 we get the following error:
Traceback (most recent call last):
File "context-manager.py", line 6, in <module>
with db.cursor() as cursor:
AttributeError: __exit__
Here's the code snippet:
import mx.ODBC.unixODBC as ODBC
connectionString = '...'
db = ODBC.DriverConnect(connectionString)
with db.cursor() as cursor:
print cursor
The mxODBC cursor is not an instance, it's implemented as Python type in C. It implements the tp_getattr slot, but not the tp_desc_get slot.
Looking at the apparently new API _PyObject_LookupSpecial(), this does not appear to support the tp_getattr slot and goes straight for the tp_desc_get slot. |
|
Date |
User |
Action |
Args |
2013-02-21 16:31:51 | lemburg | set | recipients:
+ lemburg |
2013-02-21 16:31:51 | lemburg | set | messageid: <1361464311.73.0.77004817262.issue17268@psf.upfronthosting.co.za> |
2013-02-21 16:31:51 | lemburg | link | issue17268 messages |
2013-02-21 16:31:51 | lemburg | create | |
|