windows/fixups.py: improve comments and reference some relevant Python bugs.
authordavid-sarah <david-sarah@jacaranda.org>
Tue, 27 Jul 2010 18:19:21 +0000 (11:19 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Tue, 27 Jul 2010 18:19:21 +0000 (11:19 -0700)
src/allmydata/windows/fixups.py

index 0fe5d94c5a3ccbd6a8abcc721fe02d120016e19e..92e2fc59dc1a66db29329bc76e8faa4b43f4149e 100644 (file)
@@ -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 <http://bugs.python.org/issue2128>.
     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 <http://bugs.python.org/issue8775> (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)