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.

Author torsava
Recipients torsava
Date 2021-02-03.10:43:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612348984.98.0.934369937347.issue43113@roundup.psfhosted.org>
In-reply-to
Content
os.posix_spawn fails with a wrong error information when executing an existing file with shebang pointing to a non-existing file.



$ cat demo
#!/usr/bin/hugo

$ ./demo
bash: ./demo: /usr/bin/hugo: bad interpreter: No such file or directory

$ cat repro.py
import os
os.posix_spawn("./demo", ["./demo"], {})

$ python3.10 repro.py
Traceback (most recent call last):
  File "/home/torsava/mess-old/2021-02/python-popen/repro.py", line 2, in <module>
    os.posix_spawn("./demo", ["./demo"], {})
FileNotFoundError: [Errno 2] No such file or directory: './demo'



The same problem exists when `demo` is on the PATH.



$ export PATH=".:$PATH"

$ demo
bash: ./demo: /usr/bin/hugo: bad interpreter: No such file or directory

$ cat repro_path.py
import os
os.posix_spawn("demo", ["demo"], {})

$ python3.10 repro_path.py
Traceback (most recent call last):
  File "/home/torsava/mess-old/2021-02/python-popen/repro_path.py", line 2, in <module>
    os.posix_spawn("demo", ["demo"], {})
FileNotFoundError: [Errno 2] No such file or directory: 'demo'
History
Date User Action Args
2021-02-03 10:43:05torsavasetrecipients: + torsava
2021-02-03 10:43:04torsavasetmessageid: <1612348984.98.0.934369937347.issue43113@roundup.psfhosted.org>
2021-02-03 10:43:04torsavalinkissue43113 messages
2021-02-03 10:43:04torsavacreate