[issue41615] sys.argv may be None or an empty list

2020-08-30 Thread Guido van Rossum
Guido van Rossum added the comment: Got it. On Sun, Aug 30, 2020 at 15:28 Terry J. Reedy wrote: > > > Terry J. Reedy added the comment: > > > > sys.argv cannot be set until sys exists. As I mentioned above, subsequent > calls before finalization must continue to be no-ops. > > > > Code tha

[issue41615] sys.argv may be None or an empty list

2020-08-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: sys.argv cannot be set until sys exists. As I mentioned above, subsequent calls before finalization must continue to be no-ops. Code that depends on a bug, in this case of sys.argv not existing, is always vulnerable. In this case, I would expect that peopl

[issue41615] sys.argv may be None or an empty list

2020-08-30 Thread Guido van Rossum
Guido van Rossum added the comment: Something just occurred to me. What if the caller has already set says.argv? We shouldn’t overwrite it. Or what if they only set it (later) if not already set. Would we break their code? -- --Guido (mobile) -- ___

[issue41615] sys.argv may be None or an empty list

2020-08-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: I had the same idea late last night, though after 20 years, I have forgotten how to spell "['']" in C. (Is some sort of allocation or declaration required?). In the doc, change "It does not set sys.argv; use PySys_SetArgvEx() for that." to "It initializes

[issue41615] sys.argv may be None or an empty list

2020-08-30 Thread Guido van Rossum
Guido van Rossum added the comment: I think it’s reasonable to expect sys.argv to have at least one item, possibly empty. The proposed fix of setting it to [“”] seems right to me. -- --Guido (mobile) -- ___ Python tracker

[issue41615] sys.argv may be None or an empty list

2020-08-30 Thread Jason R. Coombs
Jason R. Coombs added the comment: One possible option to guarantee initialization could be for PyInitialize to always call PySys_SetArgvEx(1, [""], 0), providing a default value for embedded interpreters that fail to call it. -- ___ Python tracke

[issue41615] sys.argv may be None or an empty list

2020-08-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: New link works and I read it, including the reference to #839151. -- ___ Python tracker ___ ___ P

[issue41615] sys.argv may be None or an empty list

2020-08-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: I just noticed that Py_Initialize "does not set sys.argv; use PySys_SetArgvEx() for that." https://docs.python.org/3/c-api/init.html#c.Py_Initialize https://docs.python.org/3/c-api/init.html#c.PySys_SetArgvEx void PySys_SetArgvEx(int argc, wchar_t **argv, int

[issue41615] sys.argv may be None or an empty list

2020-08-29 Thread Jason R. Coombs
Jason R. Coombs added the comment: Thanks Terry. The correct URL is [jaraco/keyring#445](https://github.com/jaraco/keyring/issues/445). -- ___ Python tracker ___ ___

[issue41615] sys.argv may be None or an empty list

2020-08-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: The docs are normative as well as descriptive. The specific doc for sys.argv is https://docs.python.org/3/library/sys.html#sys.argv. It says that a proper Python stdlib sys module has an args attribute that is a non-empty list whose first item is a string.

[issue41615] sys.argv may be None or an empty list

2020-08-22 Thread Jason R. Coombs
New submission from Jason R. Coombs : In [pypa/keyring#445](https://github.com/pypa/keyring/445) and issue839151, we learned that there are Python interpreters in which `sys.argv` is an empty list, is not a list, or is not initialized at all. Through use of `sys.argv[0]`, the documentation st