summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernát Gábor <bgabor8@bloomberg.net>2020-07-04 11:34:36 +0100
committerGitHub <noreply@github.com>2020-07-04 11:34:36 +0100
commit12ad5cb18bdcbdf9d66e9376c95126ab0afc5635 (patch)
treee1ebee85e515cf4ae1c8d9482cc77c544bf520d5
parent69bed3638f406f07fa107d4d8096ec9fd71f82ab (diff)
downloadvirtualenv-12ad5cb18bdcbdf9d66e9376c95126ab0afc5635.tar.gz
Do not print error if exit with SystemExit (#1886)
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 <bgabor8@bloomberg.net>
-rw-r--r--docs/changelog/1885.bugfix.rst1
-rw-r--r--src/virtualenv/__main__.py3
2 files changed, 3 insertions, 1 deletions
diff --git a/docs/changelog/1885.bugfix.rst b/docs/changelog/1885.bugfix.rst
new file mode 100644
index 0000000..6f7c9da
--- /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 c87fc41..16f12bf 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: