Message338209
> Omitting it from sys.path in that case makes sense to me, but I'm not sure what sys.argv[0] should be set to.
I propose to use ".". It would be consistent with platforms which doesn't implement realpath:
if (have_module_arg) {
#if defined(HAVE_REALPATH) || defined(MS_WINDOWS)
_Py_wgetcwd(fullpath, Py_ARRAY_LENGTH(fullpath));
argv0 = fullpath;
n = wcslen(argv0);
#else
argv0 = L".";
n = 1;
#endif
}
And it defers the error handler to later. Example of Python 3 running in a removed directory:
$ python3
Python 3.7.2 (default, Jan 16 2019, 19:49:22)
>>> import os
>>> os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
>>> os.path.abspath('.')
Traceback (most recent call last):
File "/usr/lib64/python3.7/posixpath.py", line 383, in abspath
cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
I would prefer "." than "-m". |
|
Date |
User |
Action |
Args |
2019-03-18 12:06:48 | vstinner | set | recipients:
+ vstinner, ronaldoussoren, ncoghlan, ned.deily, lkollar, pablogsal |
2019-03-18 12:06:48 | vstinner | set | messageid: <1552910808.49.0.865500869393.issue36236@roundup.psfhosted.org> |
2019-03-18 12:06:48 | vstinner | link | issue36236 messages |
2019-03-18 12:06:48 | vstinner | create | |
|