[issue43113] os.posix_spawn errors with wrong information when shebang points to not-existing file

Alexey Izbyshev report at bugs.python.org
Wed Feb 3 09:16:46 EST 2021


Alexey Izbyshev <izbyshev at ispras.ru> added the comment:

> FileNotFoundError: [Errno 2] No such file or directory: Either './demo' or the interpreter of './demo' not found.

This doesn't sound good to me because a very probable and a very improbable reasons are combined together without any distinction. Another possible issue is that usage of the word "interpreter" in this narrow sense might be non-obvious for users.

ISTM that the most minimal way to check for the possibility of interpreter issue would be do something like `access(exe_path, X_OK)` in case of ENOENT: if it's successful, then a "bad interpreter" condition is likely. But in case of os.posix_spawnp(), the search in PATH is performed by libc, so CPython doesn't know exe_path. OTOH, subprocess and os.exec*p do perform their own search in PATH, but in case of subprocess it happens in the context of the child process, so we'll probably need to devise a separate error code to report to the parent via the error pipe to distinguish this condition.

So far, I'm not convinced that the result is worth it, but I do agree that such mysterious "No such file" errors are not user-friendly.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43113>
_______________________________________


More information about the Python-bugs-list mailing list