From 85ba6567ba8798d78e6950283d7a53d8c2c30c1e Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 12 Aug 2021 12:11:39 -0400 Subject: [PATCH] Try to make sure fixed argv is used on Py27+Windows Previous version that rebound sys.argv didn't work so well with early binding used by some some functions for default argument values. --- src/allmydata/windows/fixups.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/allmydata/windows/fixups.py b/src/allmydata/windows/fixups.py index e8d05a659..53eb14d53 100644 --- a/src/allmydata/windows/fixups.py +++ b/src/allmydata/windows/fixups.py @@ -188,7 +188,17 @@ def initialize(): # for example, the Python interpreter or any options passed to it, or runner # scripts such as 'coverage run'. It works even if there are no such arguments, # as in the case of a frozen executable created by bb-freeze or similar. - sys.argv = argv[-len(sys.argv):] + # + # Also, modify sys.argv in place. If any code has already taken a + # reference to the original argument list object then this ensures that + # code sees the new values. This reliance on mutation of shared state is, + # of course, awful. Why does this function even modify sys.argv? Why not + # have a function that *returns* the properly initialized argv as a new + # list? I don't know. + # + # At least Python 3 gets sys.argv correct so before very much longer we + # should be able to fix this bad design by deleting it. + sys.argv[:] = argv[-len(sys.argv):] def a_console(handle):