New submission from Tomas Orsava <toma...@orsava.cz>:

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'

----------
components: Library (Lib)
messages: 386187
nosy: torsava
priority: normal
severity: normal
status: open
title: os.posix_spawn errors with wrong information when shebang does not exist
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43113>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to