From 2bc78e62bc036db65135e37a9bc9d7c6d6496ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 8 Dec 2016 14:51:06 +0200 Subject: [PATCH] Cause system exit only for non-zero exit statuses in setuptools command See https://github.com/pypa/setuptools/issues/850#issuecomment-265445007 --- src/flake8/main/setuptools_command.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/flake8/main/setuptools_command.py b/src/flake8/main/setuptools_command.py index f6bd7a8..ba5a260 100644 --- a/src/flake8/main/setuptools_command.py +++ b/src/flake8/main/setuptools_command.py @@ -94,4 +94,10 @@ class Flake8(setuptools.Command): self.flake8.report_statistics() self.flake8.report_benchmarks() self.flake8.formatter.stop() - self.flake8.exit() + try: + self.flake8.exit() + except SystemExit as e: + # Cause system exit only if exit code is not zero (terminates + # other possibly remaining/pending setuptools commands). + if e.code: + raise