Author gregory.p.smith
Recipients Michel Desmoulin, ammar2, gregory.p.smith, ncoghlan, r.david.murray, vstinner, xtreak, yselivanov
Date 2019-10-24.05:46:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571896007.63.0.156491545939.issue20443@roundup.psfhosted.org>
In-reply-to
Content
Please revert.  An absolute path changes semantics in many real world situations (altering symlink traversals, etc).  People expect the current sys.argv[0] behavior which is "similar to C argv" and matches what was passed on the interpreter command line.

A getcwd() call doesn't even have to succeed.  A single file python program should still be able to run in that environment rather than fail to start.

To help address the original report filing issue, we could add a notion of .co_cwd to code objects for use in resolving co_filename.  Allow it to be '' if getcwd failed at source load time.  Code could check if co_cwd exists and join it with the co_filename.  Also let co_cwd remain empty when there is no valid co_filename for the code.

Preaching: Code that calls os.chdir() is always a potential problem as it alters process global state.  That call is best avoided as modifying globals is impolite.
History
Date User Action Args
2019-10-24 05:46:47gregory.p.smithsetrecipients: + gregory.p.smith, ncoghlan, vstinner, r.david.murray, yselivanov, Michel Desmoulin, ammar2, xtreak
2019-10-24 05:46:47gregory.p.smithsetmessageid: <1571896007.63.0.156491545939.issue20443@roundup.psfhosted.org>
2019-10-24 05:46:47gregory.p.smithlinkissue20443 messages
2019-10-24 05:46:47gregory.p.smithcreate