From: david-sarah Date: Tue, 27 Jul 2010 18:19:21 +0000 (-0700) Subject: windows/fixups.py: improve comments and reference some relevant Python bugs. X-Git-Tag: allmydata-tahoe-1.8.0b2~53 X-Git-Url: https://git.rkrishnan.org/specifications/components/com_hotproperty/COPYING.TGPPL.html?a=commitdiff_plain;h=1a5a33886d771db619bfaa4559890facc89fa43e;p=tahoe-lafs%2Ftahoe-lafs.git windows/fixups.py: improve comments and reference some relevant Python bugs. --- 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)