From 11789df864154d5280e21dde29651f9fc8eeb33d Mon Sep 17 00:00:00 2001 From: tcely Date: Thu, 12 Dec 2024 13:59:06 -0500 Subject: [PATCH] Pass the exception argument Fixed up the try syntax too. I really dislike try, but it's almost mandatory in Python. --- tubesync/tubesync/sqlite3/base.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tubesync/tubesync/sqlite3/base.py b/tubesync/tubesync/sqlite3/base.py index bee1b3f4..05889640 100644 --- a/tubesync/tubesync/sqlite3/base.py +++ b/tubesync/tubesync/sqlite3/base.py @@ -26,18 +26,23 @@ class DatabaseWrapper(base.DatabaseWrapper): cursor.execute(init_cmd.strip()) - def _remove_invalid_keyword_argument(self, params): + def _remove_invalid_keyword_argument(self, arg_str, params): try: prog = re.compile(r"^(?P['])(?P[^']+)(?P=quote) is an invalid keyword argument for Connection\(\)$") - match = prog.match(e.args[0]) - - if match: + match = prog.match(arg_str) + if match is None: + return False key = match.group('key') - try: - # remove the invalid keyword argument - del params[key] - return True + # remove the invalid keyword argument + del params[key] + + return True + except: + raise + + # It's unlikely that this will ever be reached, however, + # it was left here intentionally, so don't remove it. return False @@ -56,8 +61,10 @@ class DatabaseWrapper(base.DatabaseWrapper): try: connection = super().get_new_connection(filtered_params) except TypeError as e: - if not self._remove_invalid_keyword_argument(filtered_params): + e_arg = str(e.args[0]) + if not self._remove_invalid_keyword_argument(e_arg, filtered_params): # This isn't a TypeError we can handle raise e return connection +