bpo-35794: Catch PermissionError in test_no_such_executable (GH-11635)

PermissionError can be raised if there are directories in the $PATH that are not accessible
when using posix_spawnp.
This commit is contained in:
Pablo Galindo 2019-01-21 14:35:43 +00:00 committed by GitHub
parent b2385458ce
commit e9b185f2a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1522,7 +1522,9 @@ class _PosixSpawnMixin:
pid = self.spawn_func(no_such_executable, pid = self.spawn_func(no_such_executable,
[no_such_executable], [no_such_executable],
os.environ) os.environ)
except FileNotFoundError as exc: # bpo-35794: PermissionError can be raised if there are
# directories in the $PATH that are not accessible.
except (FileNotFoundError, PermissionError) as exc:
self.assertEqual(exc.filename, no_such_executable) self.assertEqual(exc.filename, no_such_executable)
else: else:
pid2, status = os.waitpid(pid, 0) pid2, status = os.waitpid(pid, 0)