Don't pass the exception to _remove_invalid_keyword_argument

This commit is contained in:
tcely authored and GitHub committed 2024-12-12 12:31:30 -05:00
1 parent 3fe7203ed5
commit 36b395ae30
1 file changed
+11 -11
+11 -11
View File
@@ -26,22 +26,20 @@ class DatabaseWrapper(base.DatabaseWrapper):
cursor.execute(init_cmd.strip()) cursor.execute(init_cmd.strip())
def _remove_invalid_keyword_argument(self, e, filtered_params): def _remove_invalid_keyword_argument(self, params):
key = None
try: try:
prog = re.compile(r"^'(?P<key>[^']+)' is an invalid keyword argument for Connection[()]{2}$") prog = re.compile(r"^'(?P<key>[^']+)' is an invalid keyword argument for Connection[()]{2}$")
match = prog.match(e.args[0]) match = prog.match(e.args[0])
except:
raise
else: else:
if match: if match:
key = match.group('key') key = match.group('key')
finally: try:
# This isn't a TypeError we can handle # remove the invalid keyword argument
if key is None: del params[key]
raise e else:
# remove the invalid keyword argument return True
del filtered_params[key]
return False
def get_new_connection(self, conn_params): def get_new_connection(self, conn_params):
@@ -59,6 +57,8 @@ class DatabaseWrapper(base.DatabaseWrapper):
try: try:
connection = super().get_new_connection(filtered_params) connection = super().get_new_connection(filtered_params)
except TypeError as e: except TypeError as e:
self._remove_invalid_keyword_argument(e, filtered_params) if not self._remove_invalid_keyword_argument(filtered_params):
# This isn't a TypeError we can handle
raise e
return connection return connection