Why doesn't the MySQLdb Connection context manager close the cursor?
MySQLdb Connections have a rudimentary context manager that creates a cursor on enter , either rolls back or commits on exit , and implicitly doesn't suppress exceptions. From the Connection source : def __enter__(self): if self.get_autocommit(): self.query("BEGIN") return self.cursor() def __exit__(self, exc, value, tb): if exc: self.rollback() else: self.commit() So, does anyone know why the cursor isn't closed on exit? At first, I assumed it was because closing the cursor didn't do anything and that cursors only had a close method in deference to the Python DB API (see the comments to this