STINNER Victor <vstin...@python.org> added the comment:

> 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);

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue20443>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to