Henrik Stuart avatar Henrik Stuart committed 73aee70

contrib/win32: encode unicode paths for use with environment variables

os.environ expects str instances and will try to convert the unicode
strings to native strings, causing paths with non-ascii characters to
crash any hgtk operation.

Comments (0)

Files changed (1)


 # current executable to find our package data.
 import os
+import sys
 import win32api, win32process
 proc = win32api.GetCurrentProcess()
 license_path = os.path.join(bin_path, 'COPYING.txt')
 locale_path = os.path.join(bin_path, 'locale')
 icon_path = os.path.join(bin_path, 'icons')
+enc = sys.getfilesystemencoding()
+if enc:
+    bin_path = bin_path.encode(enc)
+    license_path = license_path.encode(enc)
+    locale_path = locale_path.encode(enc)
+    icon_path = icon_path.encode(enc)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.