summaryrefslogtreecommitdiff
path: root/MySQLdb
diff options
context:
space:
mode:
authorAndré Malo <ndparker@users.sf.net>2012-10-03 13:10:25 -0400
committerfarcepest <farcepest@gmail.com>2012-10-03 13:10:25 -0400
commita7f55a5d6a89cc2f3b750a2b3f06c69cf6e02a5c (patch)
tree5be27a1915c1558410b865656b3525b994ecdfce /MySQLdb
parentfa248cf6087c48c8616dad6c88f595ff7cf18cd1 (diff)
downloadmysqldb1-a7f55a5d6a89cc2f3b750a2b3f06c69cf6e02a5c.tar.gz
Patch 1/4: Minor exception handling improvements (don't swallow program exits)
https://sourceforge.net/p/mysql-python/patches/77/
Diffstat (limited to 'MySQLdb')
-rw-r--r--MySQLdb/MySQLdb/cursors.py4
-rw-r--r--MySQLdb/MySQLdb/times.py18
2 files changed, 18 insertions, 4 deletions
diff --git a/MySQLdb/MySQLdb/cursors.py b/MySQLdb/MySQLdb/cursors.py
index 50614f9..ffe60c0 100644
--- a/MySQLdb/MySQLdb/cursors.py
+++ b/MySQLdb/MySQLdb/cursors.py
@@ -174,6 +174,8 @@ class BaseCursor(object):
else:
self.messages.append((TypeError, m))
self.errorhandler(self, TypeError, m)
+ except (SystemExit, KeyboardInterrupt):
+ raise
except:
exc, value, tb = sys.exc_info()
del tb
@@ -223,6 +225,8 @@ class BaseCursor(object):
self.errorhandler(self, ProgrammingError, msg.args[0])
else:
self.errorhandler(self, TypeError, msg)
+ except (SystemExit, KeyboardInterrupt):
+ raise
except:
exc, value, tb = sys.exc_info()
del tb
diff --git a/MySQLdb/MySQLdb/times.py b/MySQLdb/MySQLdb/times.py
index 35adc7b..bc92eb4 100644
--- a/MySQLdb/MySQLdb/times.py
+++ b/MySQLdb/MySQLdb/times.py
@@ -52,6 +52,8 @@ def DateTime_or_None(s):
try:
d, t = s.split(sep, 1)
return datetime(*[ int(x) for x in d.split('-')+t.split(':') ])
+ except (SystemExit, KeyboardInterrupt):
+ raise
except:
return Date_or_None(s)
@@ -79,8 +81,12 @@ def Time_or_None(s):
return None
def Date_or_None(s):
- try: return date(*[ int(x) for x in s.split('-',2)])
- except: return None
+ try:
+ return date(*[ int(x) for x in s.split('-',2)])
+ except (SystemExit, KeyboardInterrupt):
+ raise
+ except:
+ return None
def DateTime2literal(d, c):
"""Format a DateTime object as an ISO timestamp."""
@@ -97,5 +103,9 @@ def mysql_timestamp_converter(s):
s = s + "0"*(14-len(s)) # padding
parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],
s[8:10],s[10:12],s[12:14])))
- try: return Timestamp(*parts)
- except: return None
+ try:
+ return Timestamp(*parts)
+ except (SystemExit, KeyboardInterrupt):
+ raise
+ except:
+ return None