From f3b4a9972163e6063b9d37db6352a54735955d81 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 5 Jul 2020 16:31:24 -0400 Subject: Add test for spawn when exe is missing. Ref pypa/distutils#3. --- distutils/tests/test_spawn.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/distutils/tests/test_spawn.py b/distutils/tests/test_spawn.py index 919d0ad9..704019a1 100644 --- a/distutils/tests/test_spawn.py +++ b/distutils/tests/test_spawn.py @@ -126,6 +126,11 @@ class SpawnTestCase(support.TempdirManager, rv = find_executable(program) self.assertEqual(rv, filename) + def test_spawn_missing_exe(self): + with self.assertRaises(DistutilsExecError) as ctx: + spawn(['does-not-exist']) + assert 'command does-no-exist failed' in str(ctx) + def test_suite(): return unittest.makeSuite(SpawnTestCase) -- cgit v1.2.3 From 7aa5abeafc1e0b1b351c4c8ac7eb14c310366a46 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 5 Jul 2020 16:33:16 -0400 Subject: Replace OSError with DistutilsExecError. Fixes pypa/distutils#3 and pypa/setuptools#2228 and bpo-41207. --- distutils/spawn.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/distutils/spawn.py b/distutils/spawn.py index aad277b0..0d1bd039 100644 --- a/distutils/spawn.py +++ b/distutils/spawn.py @@ -71,9 +71,15 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0): env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) - proc = subprocess.Popen(cmd, env=env) - proc.wait() - exitcode = proc.returncode + try: + proc = subprocess.Popen(cmd, env=env) + proc.wait() + exitcode = proc.returncode + except OSError as exc: + if not DEBUG: + cmd = cmd[0] + raise DistutilsExecError( + "command %r failed: %s" % (cmd, exc.args[-1])) from exc if exitcode: if not DEBUG: -- cgit v1.2.3 From ea966a23de98c04df90ba13e9fb03d1b0afe4962 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 5 Jul 2020 16:40:01 -0400 Subject: Update changelog. Ref #2228. --- changelog.d/2228.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2228.misc.rst diff --git a/changelog.d/2228.misc.rst b/changelog.d/2228.misc.rst new file mode 100644 index 00000000..be6b199d --- /dev/null +++ b/changelog.d/2228.misc.rst @@ -0,0 +1 @@ +Applied fix for pypa/distutils#3, restoring expectation that spawn will raise a DistutilsExecError when attempting to execute a missing file. -- cgit v1.2.3 From 44cec449385cac29b0f6c9719b506eb6b8c1826d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 5 Jul 2020 16:40:17 -0400 Subject: =?UTF-8?q?Bump=20version:=2049.0.0=20=E2=86=92=2049.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- CHANGES.rst | 6 ++++++ changelog.d/2228.misc.rst | 1 - setup.cfg | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 changelog.d/2228.misc.rst diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 05ff5f18..87d756b8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 49.0.0 +current_version = 49.0.1 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index bd67931d..a38b610b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,9 @@ +v49.0.1 +------- + +* #2228: Applied fix for pypa/distutils#3, restoring expectation that spawn will raise a DistutilsExecError when attempting to execute a missing file. + + v49.0.0 ------- diff --git a/changelog.d/2228.misc.rst b/changelog.d/2228.misc.rst deleted file mode 100644 index be6b199d..00000000 --- a/changelog.d/2228.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Applied fix for pypa/distutils#3, restoring expectation that spawn will raise a DistutilsExecError when attempting to execute a missing file. diff --git a/setup.cfg b/setup.cfg index d7324186..c9d108ca 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ formats = zip [metadata] name = setuptools -version = 49.0.0 +version = 49.0.1 description = Easily download, build, install, upgrade, and uninstall Python packages author = Python Packaging Authority author_email = distutils-sig@python.org -- cgit v1.2.3