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 vstinner
Recipients Michel Desmoulin, ammar2, gregory.p.smith, ncoghlan, r.david.murray, vstinner, xtreak, yselivanov
Date 2019-10-24.14:34:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571927647.84.0.976540891114.issue20443@roundup.psfhosted.org>
In-reply-to
Content
> Please revert.

Ok ok, I will revert my change, but only on sys.argv[0].


> 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.

The current implementation leaves a path unchanged if it fails to make it absolute:

config_run_filename_abspath:

    wchar_t *abs_filename;
    if (_Py_abspath(config->run_filename, &abs_filename) < 0) {
        /* failed to get the absolute path of the command line filename:
           ignore the error, keep the relative path */
        return _PyStatus_OK();
    }
    if (abs_filename == NULL) {
        return _PyStatus_NO_MEMORY();
    }

    PyMem_RawFree(config->run_filename);
    config->run_filename = abs_filename;

with:

/* Get an absolute path.
   On error (ex: fail to get the current directory), return -1.
   On memory allocation failure, set *abspath_p to NULL and return 0.
   On success, return a newly allocated to *abspath_p to and return 0.
   The string must be freed by PyMem_RawFree(). */
int _Py_abspath(const wchar_t *path, wchar_t **abspath_p);
History
Date User Action Args
2019-10-24 14:34:07vstinnersetrecipients: + vstinner, gregory.p.smith, ncoghlan, r.david.murray, yselivanov, Michel Desmoulin, ammar2, xtreak
2019-10-24 14:34:07vstinnersetmessageid: <1571927647.84.0.976540891114.issue20443@roundup.psfhosted.org>
2019-10-24 14:34:07vstinnerlinkissue20443 messages
2019-10-24 14:34:07vstinnercreate