Skip to content

Commit

Permalink
Do not print error if exit with SystemExit (#1886)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gaborbernat authored Jul 4, 2020
1 parent 69bed36 commit 12ad5cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/1885.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not print error message if the application exists with ``SystemExit(0)`` - by :user:`gaborbernat`.
3 changes: 2 additions & 1 deletion src/virtualenv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 12ad5cb

Please sign in to comment.