From 48b09d439ec3f289b3fb3ae6647ed0df35d63d14 Mon Sep 17 00:00:00 2001 From: adustman Date: Sun, 25 Feb 2007 00:16:43 +0000 Subject: [PATCH] Use setuptools instead of distutils. Add Python-2.5 support for with statement as described in http://docs.python.org/whatsnew/pep-343.html *Please test* --- MySQLdb/MySQLdb/connections.py | 8 ++++++++ MySQLdb/setup.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MySQLdb/MySQLdb/connections.py b/MySQLdb/MySQLdb/connections.py index 52128d6..92733e7 100644 --- a/MySQLdb/MySQLdb/connections.py +++ b/MySQLdb/MySQLdb/connections.py @@ -225,6 +225,14 @@ class Connection(_mysql.connection): """ return (cursorclass or self.cursorclass)(self) + def __enter__(self): return self.cursor() + + def __exit__(self, exc, value, tb): + if exc: + self.rollback() + else: + self.commit() + def literal(self, o): """ diff --git a/MySQLdb/setup.py b/MySQLdb/setup.py index 5561146..0957b9c 100644 --- a/MySQLdb/setup.py +++ b/MySQLdb/setup.py @@ -2,8 +2,8 @@ import os import sys -from distutils.core import setup -from distutils.extension import Extension +import ez_setup; ez_setup.use_setuptools() +from setuptools import setup, Extension if sys.version_info < (2, 3): raise Error, "Python-2.3 or newer is required"