Skip to content

Commit

Permalink
Don't silently swallow exceptions in python context managers
Browse files Browse the repository at this point in the history
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 e2f1a82
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/core/additions/projectdirtyblocker.py
Expand Up @@ -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
2 changes: 1 addition & 1 deletion python/core/additions/readwritecontextentercategory.py
Expand Up @@ -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
2 changes: 1 addition & 1 deletion python/core/additions/runtimeprofiler.py
Expand Up @@ -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
3 changes: 2 additions & 1 deletion python/plugins/db_manager/db_plugins/vlayers/connector.py
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions python/utils.py
Expand Up @@ -710,6 +710,7 @@ def __enter__(self):

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


#######################
Expand Down

0 comments on commit e2f1a82

Please sign in to comment.