mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 11:10:58 +08:00
Patch 1/4: Minor exception handling improvements (don't swallow program exits)
https://sourceforge.net/p/mysql-python/patches/77/
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user