diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 8d5c2d8a..828c364d 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -34,6 +34,8 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue): connection.messages.append(error) del cursor del connection + if isinstance(errorvalue, BaseException): + raise errorvalue if errorclass is not None: raise errorclass(errorvalue) else: diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 1ce6629f..a781695f 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -214,8 +214,7 @@ def execute(self, query, args=None): except (SystemExit, KeyboardInterrupt): raise except: - exc, value, tb = sys.exc_info() - del tb + exc, value = sys.exc_info()[:2] self.messages.append((exc, value)) self.errorhandler(self, exc, value) self._executed = query @@ -273,8 +272,7 @@ def executemany(self, query, args): except (SystemExit, KeyboardInterrupt): raise except: - exc, value, tb = sys.exc_info() - del tb + exc, value = sys.exc_info()[:2] self.errorhandler(self, exc, value) qs = '\n'.join([query[:p], ',\n'.join(q), query[e:]]) if not PY2: