Skip to content
Permalink
Browse files

Don't silently swallow exceptions in python context managers

Notably this causes processing modules to silently fail to load
without any warnings if the required dependancies (such as pyscopg2)
are not installed

(cherry picked from commit 1040fe8)
  • Loading branch information
nyalldawson committed Mar 19, 2021
1 parent 67a9ff6 commit e2f1a82f834b1583e7eade3d145e1bcf4c104fdf
@@ -44,4 +44,4 @@ def __enter__(self):

def __exit__(self, ex_type, ex_value, traceback):
del self.blocker
return True
return ex_type is None
@@ -43,4 +43,4 @@ def __enter__(self):

def __exit__(self, ex_type, ex_value, traceback):
del self.popper
return True
return ex_type is None
@@ -43,4 +43,4 @@ def __enter__(self):

def __exit__(self, ex_type, ex_value, traceback):
del self.profiler
return True
return ex_type is None
@@ -45,8 +45,9 @@ def __init__(self, sqlite_file):
def __enter__(self):
return self.conn

def __exit__(self, type, value, traceback):
def __exit__(self, ex_type, value, traceback):
self.conn.close()
return ex_type is None


def getQueryGeometryName(sqlite_file):
@@ -710,6 +710,7 @@ def __enter__(self):

def __exit__(self, exc_type, exc_val, exc_tb):
QApplication.restoreOverrideCursor()
return exc_type is None


#######################

0 comments on commit e2f1a82

Please sign in to comment.