From aa5e7b52567f2e79ec03978ff0f0be9443ddbffb Mon Sep 17 00:00:00 2001 From: Bernat Gabor Date: Sat, 4 Jul 2020 10:45:25 +0100 Subject: [PATCH] Do not print error if exit with SystemExit In this case Python will automatically convey the content by setting the exit code and we do not print on stderr when exiting with success. Signed-off-by: Bernat Gabor --- docs/changelog/1885.bugfix.rst | 1 + src/virtualenv/__main__.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/1885.bugfix.rst diff --git a/docs/changelog/1885.bugfix.rst b/docs/changelog/1885.bugfix.rst new file mode 100644 index 000000000..6f7c9da21 --- /dev/null +++ b/docs/changelog/1885.bugfix.rst @@ -0,0 +1 @@ +Do not print error message if the application exists with ``SystemExit(0)`` - by :user:`gaborbernat`. diff --git a/src/virtualenv/__main__.py b/src/virtualenv/__main__.py index c87fc4147..16f12bffb 100644 --- a/src/virtualenv/__main__.py +++ b/src/virtualenv/__main__.py @@ -66,7 +66,8 @@ def run_with_catch(args=None): if getattr(options, "with_traceback", False): raise else: - logging.error("%s: %s", type(exception).__name__, exception) + if not (isinstance(exception, SystemExit) and exception.code == 0): + logging.error("%s: %s", type(exception).__name__, exception) code = exception.code if isinstance(exception, SystemExit) else 1 sys.exit(code) finally: