Browse Source

Fix running hooks on windows with unicode repo paths.

Gary van der Merwe 10 years ago
parent
commit
b4e187181f
1 changed files with 6 additions and 0 deletions
  1. 6 0
      dulwich/hooks.py

+ 6 - 0
dulwich/hooks.py

@@ -20,6 +20,7 @@
 
 import os
 import subprocess
+import sys
 import tempfile
 
 from dulwich.errors import (
@@ -71,6 +72,11 @@ class ShellHook(Hook):
         self.pre_exec_callback = pre_exec_callback
         self.post_exec_callback = post_exec_callback
 
+        if sys.version_info[0] == 2 and sys.platform == 'win32':
+            # Python 2 on windows does not support unicode file paths
+            # http://bugs.python.org/issue1759845
+            self.filepath = self.filepath.encode(sys.getfilesystemencoding())
+
     def execute(self, *args):
         """Execute the hook with given args"""