From ce52dd9e3b71f2074d7821fe62803d4e0eefe512 Mon Sep 17 00:00:00 2001 From: ndparker Date: Tue, 23 Sep 2014 23:28:11 +0200 Subject: improve exception vs. exit handling --- lib/sqlalchemy/util/langhelpers.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/sqlalchemy/util/langhelpers.py') diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 76f85f605..75c6e7b46 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -490,6 +490,8 @@ def generic_repr(obj, additional_kw=(), to_inspect=None, omit_kwarg=()): val = getattr(obj, arg, missing) if val is not missing and val != defval: output.append('%s=%r' % (arg, val)) + except (SystemExit, KeyboardInterrupt): + raise except: pass @@ -499,6 +501,8 @@ def generic_repr(obj, additional_kw=(), to_inspect=None, omit_kwarg=()): val = getattr(obj, arg, missing) if val is not missing and val != defval: output.append('%s=%r' % (arg, val)) + except (SystemExit, KeyboardInterrupt): + raise except: pass @@ -1185,6 +1189,8 @@ def warn_exception(func, *args, **kwargs): """ try: return func(*args, **kwargs) + except (SystemExit, KeyboardInterrupt): + raise except: warn("%s('%s') ignored" % sys.exc_info()[0:2]) -- cgit v1.2.1 From 690532131d8ce8250c62f1d3e27405902df03e70 Mon Sep 17 00:00:00 2001 From: ndparker Date: Thu, 2 Oct 2014 22:00:31 +0200 Subject: cleanup exception handling - use new exception hierarchy (since python 2.5) --- lib/sqlalchemy/util/langhelpers.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'lib/sqlalchemy/util/langhelpers.py') diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 75c6e7b46..ea8f30e9d 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -490,9 +490,7 @@ def generic_repr(obj, additional_kw=(), to_inspect=None, omit_kwarg=()): val = getattr(obj, arg, missing) if val is not missing and val != defval: output.append('%s=%r' % (arg, val)) - except (SystemExit, KeyboardInterrupt): - raise - except: + except Exception: pass if additional_kw: @@ -501,9 +499,7 @@ def generic_repr(obj, additional_kw=(), to_inspect=None, omit_kwarg=()): val = getattr(obj, arg, missing) if val is not missing and val != defval: output.append('%s=%r' % (arg, val)) - except (SystemExit, KeyboardInterrupt): - raise - except: + except Exception: pass return "%s(%s)" % (obj.__class__.__name__, ", ".join(output)) @@ -1189,9 +1185,7 @@ def warn_exception(func, *args, **kwargs): """ try: return func(*args, **kwargs) - except (SystemExit, KeyboardInterrupt): - raise - except: + except Exception: warn("%s('%s') ignored" % sys.exc_info()[0:2]) -- cgit v1.2.1