From 2e57df917eef8769309ca4cfc4eee1d35ac532ab Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Thu, 8 Apr 2021 06:08:17 -0400 Subject: [PATCH] handle BaseExceptions properly --- archivebox/config.py | 4 +++- archivebox/logging_util.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/archivebox/config.py b/archivebox/config.py index 67987847..2afff849 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -502,11 +502,13 @@ def write_config_file(config: Dict[str, str], out_dir: str=None) -> ConfigDict: key.upper(): CONFIG.get(key.upper()) for key in config.keys() } - except BaseException: + except BaseException: # lgtm [py/catch-base-exception] # something went horribly wrong, rever to the previous version with open(f'{config_path}.bak', 'r', encoding='utf-8') as old: atomic_write(config_path, old.read()) + raise + if Path(f'{config_path}.bak').exists(): os.remove(f'{config_path}.bak') diff --git a/archivebox/logging_util.py b/archivebox/logging_util.py index d0972191..92a0f61d 100644 --- a/archivebox/logging_util.py +++ b/archivebox/logging_util.py @@ -157,7 +157,10 @@ class TimedProgress: # kill the progress bar subprocess try: self.p.close() # must be closed *before* its terminnated - except BaseException: + except (KeyboardInterrupt, SystemExit): + print() + raise + except BaseException: # lgtm [py/catch-base-exception] pass self.p.terminate() self.p.join()