This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_posix.TestPosixSpawnP.test_no_such_executable() fails with NotADirectoryError on Debian
Type: behavior Stage: test needed
Components: Library (Lib), Tests Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jaguardown, larry, terry.reedy, vstinner
Priority: normal Keywords:

Created on 2020-02-16 17:15 by jaguardown, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg362084 - (view) Author: Zachary (jaguardown) Date: 2020-02-16 17:15
Forgive me, for I am a newb and this is the first Python issue I have ever created.

My system:
Linux debian-thinkpad 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64 GNU/Linux

While attempting to run "make test" test_posix failed. As you can see in the output apparently test_posix.py can't find a directory.

I'm not sure if I can paste output here without it being illegible so I'm putting it in a paste:
https://pastebin.com/xfqEzKiw
msg362449 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-02-22 06:24
======================================================================
ERROR: test_no_such_executable (test.test_posix.TestPosixSpawnP)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/zachary/Python-3.8.1/Lib/test/test_posix.py", line 1529, in test_no_such_executable
    pid = self.spawn_func(no_such_executable,
NotADirectoryError: [Errno 20] Not a directory: 'no_such_executable'

is all that is needed.
msg362555 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-02-24 01:23
My understanding that Python is compiled and installed and that the failure was during a later test.

In repository master (3.9) the line is 1549 instead of 1529.  The test function code is

    def test_no_such_executable(self):
        no_such_executable = 'no_such_executable'
        try:
            pid = self.spawn_func(no_such_executable,
                                  [no_such_executable],
                                  os.environ)
        # 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)
        else:
            pid2, status = os.waitpid(pid, 0)
            self.assertEqual(pid2, pid)
            self.assertNotEqual(status, 0)

It is part of a mixin class and once mixed in, spawn_func is either posix_spawn or posix_spawnp.  The first parameter is 'path'.

"The path parameter is the path to the executable file.The path should contain a directory.  Use posix_spawnp() to pass an executable file without directory."

FileNotFoundError and PermissionError are subclasses of OSError.  So is NotADirectoryError.  I was initially tempted to say that either the latter should be added to the tuple or that the tuple should be replaced by OSError.  However, the test failed with posix_spawnp, when the path should not be required to have a directory.  So I wonder if there is a problem with this function on this Debian.  (I do not work with Linux at all.)

Zachary, could you try adding NotADirectoryError to the exception list and see if the test
    self.assertEqual(exc.filename, no_such_executable)
passes?
msg363021 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-29 22:27
Which exception do you get for the following code?

import os
args=['no_such_executable']
os.execve(args[0], args, os.environ)
msg363022 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-29 22:28
And for this one?

import os
args=['no_such_executable']
os.execvpe(args[0], args, os.environ)
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83834
2020-02-29 22:29:38vstinnersettitle: test_posix fails during make test -> test_posix.TestPosixSpawnP.test_no_such_executable() fails with NotADirectoryError on Debian
2020-02-29 22:28:57vstinnersetmessages: + msg363022
2020-02-29 22:27:37vstinnersetmessages: + msg363021
2020-02-24 01:23:48terry.reedysetnosy: + vstinner, larry
messages: + msg362555

components: + Library (Lib), Tests, - Installation
type: compile error -> behavior
stage: test needed
2020-02-22 06:24:31terry.reedysetnosy: + terry.reedy
messages: + msg362449
2020-02-16 17:15:32jaguardowncreate