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 gregory.p.smith
Recipients eric.smith, gregory.p.smith, hroncok, izbyshev, nanjekyejoannah, pablogsal, torsava, vstinner
Date 2021-02-04.19:42:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612467732.19.0.713061057628.issue43113@roundup.psfhosted.org>
In-reply-to
Content
That bash produces a nicer error message is because bash happens to implement its own special logic to try and figure out why an exec failed with an error other than ENOEXEC.  The OS kernel & libc do not give it that information, there is no such errno.  Bash inspects the executable itself for a #! in some error paths, extracts an interpreter from that and constructs an error message involving it.  (bash's execute_cmd.c and HAVE_HASH_BANG_EXEC logic)

I agree with Eric.  I don't think we should do anything here.  This isn't posix_spawn, subprocess, or os.exec* specific.  It's just how posix-y OSes that have the concept of a #! line interpreter for executable files work.  The errno that comes back from an exec failure is not super informative.

If someone disagrees, the way to move forward on this is to implement equivalent logic in a central place and have it called from all of the relevant places within the posixmodule (os) and the _posixsubprocess module.  With tests of all possible errno cases and code paths for each.  And make a PR out of that.

If you're going to take that on; do _not_ look at the bash source code.  That's GPL, we cannot copy it.  Just go by this description.

To me, this seems over complicated to get right and maintain.  I'd rather not do this within Python.  But if someone is going to make a PR for it, I'll at least look at it to see if it seems like something we could accept maintenance of.  I cannot guarantee we'd accept it.
History
Date User Action Args
2021-02-04 19:42:12gregory.p.smithsetrecipients: + gregory.p.smith, vstinner, eric.smith, torsava, izbyshev, hroncok, pablogsal, nanjekyejoannah
2021-02-04 19:42:12gregory.p.smithsetmessageid: <1612467732.19.0.713061057628.issue43113@roundup.psfhosted.org>
2021-02-04 19:42:12gregory.p.smithlinkissue43113 messages
2021-02-04 19:42:12gregory.p.smithcreate