changeset 31277:86cd1f2cfff5 stable

pycompat: verify sys.argv exists before forwarding it (issue5493) ISAPI_WSGI doesn't set up sys.argv, so we have to look for the attribute before assuming it exists.
author Augie Fackler <augie@google.com>
date Tue, 07 Mar 2017 13:24:24 -0500
parents 6b00c3ecd15b
children 295625f1296b ffed3bf5cd4c
files mercurial/pycompat.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pycompat.py	Thu Mar 02 20:19:45 2017 -0500
+++ b/mercurial/pycompat.py	Tue Mar 07 13:24:24 2017 -0500
@@ -69,7 +69,8 @@
     #
     # TODO: On Windows, the native argv is wchar_t, so we'll need a different
     # workaround to simulate the Python 2 (i.e. ANSI Win32 API) behavior.
-    sysargv = list(map(os.fsencode, sys.argv))
+    if getattr(sys, 'argv', None) is not None:
+        sysargv = list(map(os.fsencode, sys.argv))
 
     def sysstr(s):
         """Return a keyword str to be passed to Python functions such as
@@ -165,7 +166,8 @@
     stdin = sys.stdin
     stdout = sys.stdout
     stderr = sys.stderr
-    sysargv = sys.argv
+    if getattr(sys, 'argv', None) is not None:
+        sysargv = sys.argv
     sysplatform = sys.platform
     getcwd = os.getcwd
     sysexecutable = sys.executable