[New-bugs-announce] [issue43113] os.posix_spawn errors with wrong information when shebang does not exist

Tomas Orsava report at bugs.python.org
Wed Feb 3 05:43:04 EST 2021


New submission from Tomas Orsava <tomas.n at 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 <report at bugs.python.org>
<https://bugs.python.org/issue43113>
_______________________________________


More information about the New-bugs-announce mailing list