From 00e482f661267945eea49d9d78d93150b6dfc6df Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 30 Apr 2020 16:49:54 +0200 Subject: [PATCH] TT#80825 utils/kamctl/dbtextdb/dbtextdb.py: fix exception usage with python3 Fails due to: | Traceback (most recent call last): | File "/usr/lib/x86_64-linux-gnu/kamailio/kamctl/dbtextdb/dbtextdb.py", line 1239, in | main(sys.argv) | File "/usr/lib/x86_64-linux-gnu/kamailio/kamctl/dbtextdb/dbtextdb.py", line 1233, in main | except (Error, e): | NameError: name 'e' is not defined Change-Id: I09ed6d0bd1b6fdad5f9b04cd54fef1ee43a44312 --- debian/patches/series | 1 + .../sipwise/dbtextdb_fix_exception_handling | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 debian/patches/sipwise/dbtextdb_fix_exception_handling diff --git a/debian/patches/series b/debian/patches/series index 6bf742f55..1fcce9ae8 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -76,6 +76,7 @@ sipwise/rtpengine-flags-for-everything.patch sipwise/pv_headers-full-rework.patch sipwise/pua_dialoginfo-refresh_pubruri_avps_flag.patch sipwise/pua_dialoginfo-local_identity_dlg_var.patch +sipwise/dbtextdb_fix_exception_handling # ### Don't just put stuff in any order ### use gbp pq import/export tooling to help maintain patches diff --git a/debian/patches/sipwise/dbtextdb_fix_exception_handling b/debian/patches/sipwise/dbtextdb_fix_exception_handling new file mode 100644 index 000000000..0cbe742cf --- /dev/null +++ b/debian/patches/sipwise/dbtextdb_fix_exception_handling @@ -0,0 +1,35 @@ +--- a/utils/kamctl/dbtextdb/dbtextdb.py ++++ b/utils/kamctl/dbtextdb/dbtextdb.py +@@ -993,12 +993,12 @@ + try: + if val: + val = eval(val) +- except (NameError, e): ++ except NameError as e: + raise ExecuteError('Failed to parse %s in %s ' + '(unable to convert to type %s): %s' % + (col, self.table, self.header[col]['type'], + e)) +- except (SyntaxError, e): ++ except SyntaxError as e: + raise ExecuteError('Failed to parse %s in %s ' + '(unable to convert to type %s): %s' % + (col, self.table, self.header[col]['type'], +@@ -1083,7 +1083,7 @@ + # save a copy of the data before modifying + self.orig_data = self.data[:] + +- except (IOError, e): ++ except IOError as e: + raise ExecuteError('Unable to open table %s: %s' % (self.table, e)) + + Debug('Header is: %s' % self.header) +@@ -1230,7 +1230,7 @@ + print('Updated %s, rows affected: %d' % (conn.table, row)) + else: + print(row) +- except (Error, e): ++ except Error as e: + print(e) + sys.exit(1) +