diff --git a/AUTHORS b/AUTHORS index fefddefb1..cac2b38dc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -135,6 +135,7 @@ Contributors: * Andrew M. MacFie (amacfie) * saucoide * Chris Rose (offbyone/offby1) + * Chris Novakovic Creator: -------- diff --git a/changelog.rst b/changelog.rst index 5113a3095..47e45b88f 100644 --- a/changelog.rst +++ b/changelog.rst @@ -5,6 +5,10 @@ Features -------- * Add a `--ping` command line option; allows pgcli to replace `pg_isready` +Bug fixes: +---------- +* Avoid raising `NameError` when exiting unsuccessfully in some cases + 4.1.0 (2024-03-09) ================== diff --git a/pgcli/main.py b/pgcli/main.py index f07255e56..d4c6dbf6d 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -610,7 +610,7 @@ def connect_service(self, service, user): click.secho( f"service '{service}' was not found in {file}", err=True, fg="red" ) - exit(1) + sys.exit(1) self.connect( database=service_config.get("dbname"), host=service_config.get("host"), @@ -710,7 +710,7 @@ def should_ask_for_password(exc): self.logger.handlers = logger_handlers self.logger.error("traceback: %r", traceback.format_exc()) click.secho(str(e), err=True, fg="red") - exit(1) + sys.exit(1) self.logger.handlers = logger_handlers atexit.register(self.ssh_tunnel.stop) @@ -763,7 +763,7 @@ def should_ask_for_password(exc): self.logger.debug("Database connection failed: %r.", e) self.logger.error("traceback: %r", traceback.format_exc()) click.secho(str(e), err=True, fg="red") - exit(1) + sys.exit(1) self.pgexecute = pgexecute @@ -1551,7 +1551,7 @@ def cli( err=True, fg="red", ) - exit(1) + sys.exit(1) if ssh_tunnel and not SSH_TUNNEL_SUPPORT: click.secho( @@ -1560,7 +1560,7 @@ def cli( err=True, fg="red", ) - exit(1) + sys.exit(1) pgcli = PGCli( prompt_passwd, @@ -1604,7 +1604,7 @@ def cli( err=True, fg="red", ) - exit(1) + sys.exit(1) except Exception: click.secho( "Invalid DSNs found in the config file. " @@ -1612,7 +1612,7 @@ def cli( err=True, fg="red", ) - exit(1) + sys.exit(1) pgcli.connect_uri(dsn_config) pgcli.dsn_alias = dsn elif "://" in database: