From 1a5a33886d771db619bfaa4559890facc89fa43e Mon Sep 17 00:00:00 2001 From: david-sarah Date: Tue, 27 Jul 2010 11:19:21 -0700 Subject: [PATCH] windows/fixups.py: improve comments and reference some relevant Python bugs. --- src/allmydata/windows/fixups.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/allmydata/windows/fixups.py b/src/allmydata/windows/fixups.py index 0fe5d94c..92e2fc59 100644 --- a/src/allmydata/windows/fixups.py +++ b/src/allmydata/windows/fixups.py @@ -159,7 +159,7 @@ def initialize(): except Exception, e: _complain("exception %r while fixing up sys.stdout and sys.stderr" % (e,)) - # Unmangle command-line arguments. + # This works around . GetCommandLineW = WINFUNCTYPE(LPWSTR)(("GetCommandLineW", windll.kernel32)) CommandLineToArgvW = WINFUNCTYPE(POINTER(LPWSTR), LPCWSTR, POINTER(c_int)) \ (("CommandLineToArgvW", windll.shell32)) @@ -167,6 +167,10 @@ def initialize(): argc = c_int(0) argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc)) + # Because of (and similar limitations in + # twisted), the 'bin/tahoe' script cannot invoke us with the actual Unicode arguments. + # Instead it "mangles" or escapes them using \x7f as an escape character, which we + # unescape here. def unmangle(s): return re.sub(ur'\x7f[0-9a-fA-F]*\;', lambda m: unichr(int(m.group(0)[1:-1], 16)), s) -- 2.45.2