From 158fae28f581536498b37639304ecb6e509c9a60 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Mon, 4 May 2020 20:54:36 +0200 Subject: [PATCH] TT#80825 upstream fixes for kamctl dbtextdb Change-Id: I214959c0721263c3577e575938067091e1ce328b --- debian/patches/series | 5 +- .../sipwise/dbtextdb_fix_exception_handling | 35 --- ...extdb-remove-DeprecationWarning-on-t.patch | 241 ++++++++++++++++++ ...extdb.py-close-previous-opened-file-.patch | 39 +++ .../upstream/utils-kamctl-fix-dbtestdb.patch | 89 +++++++ ...ls-kamctl-fix-handling-of-Exceptions.patch | 88 +++++++ 6 files changed, 461 insertions(+), 36 deletions(-) delete mode 100644 debian/patches/sipwise/dbtextdb_fix_exception_handling create mode 100644 debian/patches/upstream/utils-kamctl-dbtextdb-remove-DeprecationWarning-on-t.patch create mode 100644 debian/patches/upstream/utils-kamctl-dbtextdb.py-close-previous-opened-file-.patch create mode 100644 debian/patches/upstream/utils-kamctl-fix-dbtestdb.patch create mode 100644 debian/patches/upstream/utils-kamctl-fix-handling-of-Exceptions.patch diff --git a/debian/patches/series b/debian/patches/series index 1fcce9ae8..0feceb817 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -68,6 +68,10 @@ upstream/rtpengine-fix-zero-length-log-placeholder.patch upstream/core-fix-returning-multiple-IPs-for-a-cached-DNS-ent.patch upstream/core-do-not-set-msg-tcp-connection-id-in-the-dst-inf.patch upstream/tm-do-not-set-msg-tcp-connection-id-in-the-dst-info.patch +upstream/utils-kamctl-fix-handling-of-Exceptions.patch +upstream/utils-kamctl-fix-dbtestdb.patch +upstream/utils-kamctl-dbtextdb-remove-DeprecationWarning-on-t.patch +upstream/utils-kamctl-dbtextdb.py-close-previous-opened-file-.patch ### relevant for upstream sipwise/fix_error_in_cfgt_module.patch sipwise/pv_headers-store-To-info-in-xavp_parsed_name.r-on-re.patch @@ -76,7 +80,6 @@ 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 deleted file mode 100644 index 0cbe742cf..000000000 --- a/debian/patches/sipwise/dbtextdb_fix_exception_handling +++ /dev/null @@ -1,35 +0,0 @@ ---- 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) - diff --git a/debian/patches/upstream/utils-kamctl-dbtextdb-remove-DeprecationWarning-on-t.patch b/debian/patches/upstream/utils-kamctl-dbtextdb-remove-DeprecationWarning-on-t.patch new file mode 100644 index 000000000..2c31db2b4 --- /dev/null +++ b/debian/patches/upstream/utils-kamctl-dbtextdb-remove-DeprecationWarning-on-t.patch @@ -0,0 +1,241 @@ +From 5a90c8bc600fe9a93a5ce4f828ce50f3bf532b99 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Mon, 4 May 2020 15:05:23 +0200 +Subject: [PATCH] utils/kamctl: dbtextdb remove DeprecationWarning on test + +related #1747 + +(cherry picked from commit 765efa80c7d27e9447bc1ad8a354ee24723580ef) +--- + utils/kamctl/dbtextdb/dbtextdb_test.py | 120 ++++++++++++------------- + 1 file changed, 60 insertions(+), 60 deletions(-) + +diff --git a/utils/kamctl/dbtextdb/dbtextdb_test.py b/utils/kamctl/dbtextdb/dbtextdb_test.py +index ecbab06742..54ce274c72 100644 +--- a/utils/kamctl/dbtextdb/dbtextdb_test.py ++++ b/utils/kamctl/dbtextdb/dbtextdb_test.py +@@ -8,8 +8,8 @@ __author__ = 'herman@google.com (Herman Sheremetyev)' + + import time + import unittest +-from dbtextdb import * +- ++from dbtextdb import DBText ++from dbtextdb import ParseError, ExecuteError + + class DBTextTest(unittest.TestCase): + +@@ -25,28 +25,28 @@ class DBTextTest(unittest.TestCase): + # normal query + query_normal = 'select * from subscriber;' + db_conn.ParseQuery(query_normal) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.columns == ['*']) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.columns, ['*']) + db_conn.CleanUp() + # normal query with condition + query_normal_cond = 'select * from subscriber where column="value";' + db_conn.ParseQuery(query_normal_cond) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.columns == ['*']) +- self.assert_(db_conn.strings == ['value']) +- self.assert_(not db_conn.count) +- self.assert_(db_conn.conditions == {'column': 'value'}) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.columns, ['*']) ++ self.assertEqual(db_conn.strings, ['value']) ++ self.assertTrue(not db_conn.count) ++ self.assertEqual(db_conn.conditions, {'column': 'value'}) + db_conn.CleanUp() + # normal query with multiple conditions + query_normal_cond = ('select * from subscriber where column="value1" and ' + 'col2=" another value " and col3= foo and a="";') + db_conn.ParseQuery(query_normal_cond) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.columns == ['*']) +- self.assert_(db_conn.strings == ['value1', ' another value ', '']) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.columns, ['*']) ++ self.assertEqual(db_conn.strings, ['value1', ' another value ', '']) + self.assertEqual(db_conn.conditions, {'column': 'value1', + 'col2': ' another value ', + 'col3': 'foo', 'a': ''}) +@@ -54,49 +54,49 @@ class DBTextTest(unittest.TestCase): + # normal query with count + query_normal_count = 'select count(*) from subscriber;' + db_conn.ParseQuery(query_normal_count) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.columns == ['*']) +- self.assert_(db_conn.count == True) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.columns, ['*']) ++ self.assertEqual(db_conn.count, True) + db_conn.CleanUp() + # normal query with now() + query_normal_count = 'select count(*) from subscriber where time=now();' + db_conn.ParseQuery(query_normal_count) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.columns == ['*']) +- self.assert_(db_conn.count == True) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.columns, ['*']) ++ self.assertEqual(db_conn.count, True) + self.assertEqual(db_conn.conditions, {'time': self.time_now}) + db_conn.CleanUp() + # normal delete query + query_normal_delete = 'delete from subscriber where foo = 2;' + db_conn.ParseQuery(query_normal_delete) +- self.assert_(db_conn.command == 'DELETE') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'DELETE') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.conditions, {'foo': '2'}) + db_conn.CleanUp() + # normal insert values query with no into + query_normal_insert_values = ('insert subscriber (col1, col2, col3) ' + 'values (1, "foo", "");') + db_conn.ParseQuery(query_normal_insert_values) +- self.assert_(db_conn.command == 'INSERT') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'INSERT') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.targets, {'col1': '1', 'col2': 'foo', 'col3': ''}) + db_conn.CleanUp() + # normal insert values query with into + query_normal_insert_into_values = ('insert into subscriber (col1, col2) ' + 'values (1, "foo");') + db_conn.ParseQuery(query_normal_insert_into_values) +- self.assert_(db_conn.command == 'INSERT') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'INSERT') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.targets, {'col1': '1', 'col2': 'foo'}) + db_conn.CleanUp() + # normal insert values query with now() + query_normal_insert_into_values = ('insert into subscriber (a, b, c) ' + 'values (NOW(), "foo", now());') + db_conn.ParseQuery(query_normal_insert_into_values) +- self.assert_(db_conn.command == 'INSERT') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'INSERT') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.targets, {'a': self.time_now, 'b': 'foo', + 'c': self.time_now}) + db_conn.CleanUp() +@@ -157,23 +157,23 @@ class DBTextTest(unittest.TestCase): + # normal insert set query with no into + query_normal_insert_set = ('insert subscriber set col= 1, col2 ="\'f\'b";') + db_conn.ParseQuery(query_normal_insert_set) +- self.assert_(db_conn.command == 'INSERT') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'INSERT') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.targets, {'col': '1', 'col2': '\'f\'b'}) + db_conn.CleanUp() + # normal update + query_normal_update = ('update subscriber set col1= 1, col2 ="foo";') + db_conn.ParseQuery(query_normal_update) +- self.assert_(db_conn.command == 'UPDATE') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'UPDATE') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.targets, {'col1': '1', 'col2': 'foo'}) + db_conn.CleanUp() + # normal update with condition + query_normal_update_cond = ('update subscriber set col1= 1, col2 ="foo" ' + 'where foo = "bar" and id=1 and a="";') + db_conn.ParseQuery(query_normal_update_cond) +- self.assert_(db_conn.command == 'UPDATE') +- self.assert_(db_conn.table == 'subscriber') ++ self.assertEqual(db_conn.command, 'UPDATE') ++ self.assertEqual(db_conn.table, 'subscriber') + self.assertEqual(db_conn.targets, {'col1': '1', 'col2': 'foo'}) + self.assertEqual(db_conn.conditions, {'foo': 'bar', 'id': '1', 'a': ''}) + db_conn.CleanUp() +@@ -220,49 +220,49 @@ class DBTextTest(unittest.TestCase): + # normal query with multiple columns + query_normal_count = 'select col1, "col 2",col3 , "col4" from subscriber;' + db_conn.ParseQuery(query_normal_count) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.strings == ['col 2', 'col4']) +- self.assert_(db_conn.columns == ['col1', "'col 2'", 'col3', "'col4'"]) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.strings, ['col 2', 'col4']) ++ self.assertEqual(db_conn.columns, ['col1', "'col 2'", 'col3', "'col4'"]) + db_conn.CleanUp() + # normal query with ORDER BY + query_normal_order_by = ('select col1, col2 from test' + ' ORDER by col1;') + db_conn.ParseQuery(query_normal_order_by) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'test') +- self.assert_(db_conn.columns == ['col1', 'col2']) +- self.assert_(db_conn.order_by == 'col1') ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'test') ++ self.assertEqual(db_conn.columns, ['col1', 'col2']) ++ self.assertEqual(db_conn.order_by, 'col1') + db_conn.CleanUp() + # normal query with ORDER BY with conditions + query_normal_order_by_cond = ('select col1, col2 from test where col="asdf"' + ' and col2 = "foo" ORDER by col;') + db_conn.ParseQuery(query_normal_order_by_cond) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'test') +- self.assert_(db_conn.columns == ['col1', 'col2']) +- self.assert_(db_conn.conditions == {'col': 'asdf', 'col2': 'foo'}) +- self.assert_(db_conn.order_by == 'col') ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'test') ++ self.assertEqual(db_conn.columns, ['col1', 'col2']) ++ self.assertEqual(db_conn.conditions, {'col': 'asdf', 'col2': 'foo'}) ++ self.assertEqual(db_conn.order_by, 'col') + db_conn.CleanUp() + # normal query with CONCAT + query_normal_concat = ('select concat(uname,"@", domain) as email_addr ' + 'from subscriber where id=3;') + db_conn.ParseQuery(query_normal_concat) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'subscriber') +- self.assert_(db_conn.columns == ['email_addr']) +- self.assert_(db_conn.conditions == {'id': '3'}) +- self.assert_(db_conn.aliases == {'email_addr': ['uname', "'@'", 'domain']}) ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'subscriber') ++ self.assertEqual(db_conn.columns, ['email_addr']) ++ self.assertEqual(db_conn.conditions, {'id': '3'}) ++ self.assertEqual(db_conn.aliases, {'email_addr': ['uname', "'@'", 'domain']}) + db_conn.CleanUp() + # normal query with multiple CONCAT + query_normal_mult_concat = ('select concat(uname,"@", domain) as email,' + ' foo as "bar" from table where id=3;') + db_conn.ParseQuery(query_normal_mult_concat) +- self.assert_(db_conn.command == 'SELECT') +- self.assert_(db_conn.table == 'table') +- self.assert_(db_conn.columns == ['email', "'bar'"]) +- self.assert_(db_conn.conditions == {'id': '3'}) +- self.assert_(db_conn.aliases == {"'bar'": ['foo'], ++ self.assertEqual(db_conn.command, 'SELECT') ++ self.assertEqual(db_conn.table, 'table') ++ self.assertEqual(db_conn.columns, ['email', "'bar'"]) ++ self.assertEqual(db_conn.conditions, {'id': '3'}) ++ self.assertTrue(db_conn.aliases == {"'bar'": ['foo'], + 'email': ['uname', "'@'", 'domain']}) + db_conn.CleanUp() + # bad query with CONCAT missing AS +-- +2.26.2 + diff --git a/debian/patches/upstream/utils-kamctl-dbtextdb.py-close-previous-opened-file-.patch b/debian/patches/upstream/utils-kamctl-dbtextdb.py-close-previous-opened-file-.patch new file mode 100644 index 000000000..701f8c056 --- /dev/null +++ b/debian/patches/upstream/utils-kamctl-dbtextdb.py-close-previous-opened-file-.patch @@ -0,0 +1,39 @@ +From e26e587f31eb23c431a2cfb149ec7a86b4f648bc Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Mon, 4 May 2020 15:22:36 +0200 +Subject: [PATCH] utils/kamctl: dbtextdb.py close previous opened file properly + +related #1747 + +(cherry picked from commit 5f52f9905bbdf63d636080f7d0340af4f71ed12a) +--- + utils/kamctl/dbtextdb/dbtextdb.py | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py +index 7e1de04687..581496c309 100755 +--- a/utils/kamctl/dbtextdb/dbtextdb.py ++++ b/utils/kamctl/dbtextdb/dbtextdb.py +@@ -60,6 +60,10 @@ class DBText(object): + if not os.path.isdir(location): + raise ParseError(location + ' is not a directory') + ++ def __del__(self): ++ if getattr(self, 'fd', False): ++ self.fd.close() ++ + def _ParseOrderBy(self): + """Parse out the column name to be used for ordering the dataset. + +@@ -438,6 +442,8 @@ class DBText(object): + self.command = '' # which command are we executing + self.strings = [] # list of string literals parsed from the query + self.parens = [] # list of parentheses parsed from the query ++ if getattr(self, 'fd', False): ++ self.fd.close() + + def ParseQuery(self, query): + """External wrapper for the query parsing routines. +-- +2.26.2 + diff --git a/debian/patches/upstream/utils-kamctl-fix-dbtestdb.patch b/debian/patches/upstream/utils-kamctl-fix-dbtestdb.patch new file mode 100644 index 000000000..b41a213df --- /dev/null +++ b/debian/patches/upstream/utils-kamctl-fix-dbtestdb.patch @@ -0,0 +1,89 @@ +From c4dd3218e6b723c688762a5c4253fa70f3f588bc Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Mon, 4 May 2020 14:01:33 +0200 +Subject: [PATCH] utils/kamctl: fix dbtestdb + +some indentantion errors introduced at https://github.com/kamailio/kamailio/commit/bc8bdcaa726f375f6deea8228a1ab0cf97c67035 + +related #1747 + +(cherry picked from commit b722a48144ac9e029bdbc2968dedbe56966a3f7c) +--- + utils/kamctl/dbtextdb/dbtextdb.py | 38 +++++++++++++++---------------- + 1 file changed, 19 insertions(+), 19 deletions(-) + +diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py +index 3d5ee7ecc5..7e1de04687 100755 +--- a/utils/kamctl/dbtextdb/dbtextdb.py ++++ b/utils/kamctl/dbtextdb/dbtextdb.py +@@ -146,11 +146,11 @@ class DBText(object): + # check if there is a function modifier on the columns + if self.tokens[0] == 'COUNT': + self.count = True +- if col_end == 1: +- raise ParseError('COUNT must be followed by column name[s]') +- if not self.tokens[1].startswith(self._paren_placeholder): +- raise ParseError('COUNT must be followed by ()') +- cols_str = self._ReplaceParens(self.tokens[1]) ++ if col_end == 1: ++ raise ParseError('COUNT must be followed by column name[s]') ++ if not self.tokens[1].startswith(self._paren_placeholder): ++ raise ParseError('COUNT must be followed by ()') ++ cols_str = self._ReplaceParens(self.tokens[1]) + + cols = cols_str.split(',') + for col in cols: +@@ -300,7 +300,7 @@ class DBText(object): + if self.tokens.pop(0) != 'SET': + raise ParseError('UPDATE command must be followed by SET') + +- self.targets = self._ParsePairs(' '.join(self.tokens), ',') ++ self.targets = self._ParsePairs(' '.join(self.tokens), ',') + + # INSERT + if self.command == 'INSERT': +@@ -570,19 +570,19 @@ class DBText(object): + string = '%s%s' % (string, c) + continue # wait for matching delim + +- started -= 1 +- if not started: +- values.append(string) +- new_args = '%s %s' % (new_args, '%s%d' % (placeholder, +- my_id)) +- my_id += 1 +- string = '' ++ started -= 1 ++ if not started: ++ values.append(string) ++ new_args = '%s %s' % (new_args, '%s%d' % (placeholder, ++ my_id)) ++ my_id += 1 ++ string = '' + +- else: +- if not started: +- new_args = '%s%s' % (new_args, c) + else: +- string = '%s%s' % (string, c) ++ if not started: ++ new_args = '%s%s' % (new_args, c) ++ else: ++ string = '%s%s' % (string, c) + + if started: + if mode == 'parens': +@@ -714,8 +714,8 @@ class DBText(object): + elif self.header[col]['auto']: + new_row[col] = self._GetNextAuto(col) + +- else: +- raise ExecuteError(col + ' cannot be empty or null') ++ else: ++ raise ExecuteError(col + ' cannot be empty or null') + + self.data.append(new_row) + return [1] +-- +2.26.2 + diff --git a/debian/patches/upstream/utils-kamctl-fix-handling-of-Exceptions.patch b/debian/patches/upstream/utils-kamctl-fix-handling-of-Exceptions.patch new file mode 100644 index 000000000..d075469fd --- /dev/null +++ b/debian/patches/upstream/utils-kamctl-fix-handling-of-Exceptions.patch @@ -0,0 +1,88 @@ +From 5f6f4331811e654e75b49263f8fb823bea9874a3 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Mon, 4 May 2020 11:33:12 +0200 +Subject: [PATCH] utils/kamctl: fix handling of Exceptions + +> 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 + +(cherry picked from commit 1aca79c43cb8dbd920c1eb81c0c30cf89f0985b9) +--- + utils/kamctl/dbtextdb/dbtextdb.py | 22 ++++++++++------------ + 1 file changed, 10 insertions(+), 12 deletions(-) + +diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py +index 3a35554013..3d5ee7ecc5 100755 +--- a/utils/kamctl/dbtextdb/dbtextdb.py ++++ b/utils/kamctl/dbtextdb/dbtextdb.py +@@ -356,7 +356,7 @@ class DBText(object): + # test that the value is string, if not return it as is + try: + value.find('a') +- except: ++ except Exception: + return value + + escaped = value +@@ -377,7 +377,7 @@ class DBText(object): + # test that the value is string, if not return it as is + try: + value.find('a') +- except: ++ except Exception: + return value + + escaped = value +@@ -988,21 +988,19 @@ class DBText(object): + if not val and not self.header[col]['null']: + raise ExecuteError(col + ' cannot be empty or null') + +- if (self.header[col]['type'].lower() == 'int' or +- self.header[col]['type'].lower() == 'double'): ++ hdr_t = self.header[col]['type'].lower() ++ if hdr_t == 'int' or hdr_t == 'double': + 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): ++ (col, self.table, hdr_t, 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'], +- e)) ++ (col, self.table, hdr_t, e)) + + return val + +@@ -1083,7 +1081,7 @@ class DBText(object): + # 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 +1228,7 @@ def main(argv): + print('Updated %s, rows affected: %d' % (conn.table, row)) + else: + print(row) +- except (Error, e): ++ except Error as e: + print(e) + sys.exit(1) + +-- +2.26.2 +