@@ -36,7 +36,7 @@ def __init__(self, file_path):
3636
3737 def __del__ (self ):
3838 if os .path .isfile (self .tmp_file_path ):
39- if sys . platform == "win32" and os .path .exists (self .file_path ):
39+ if os . name == 'nt' and os .path .exists (self .file_path ):
4040 os .remove (self .file_path )
4141 os .rename (self .tmp_file_path , self .file_path )
4242 # END temp file exists
@@ -243,9 +243,10 @@ def _set_cache_(self, attr):
243243 if attr == "entries" :
244244 # read the current index
245245 # try memory map for speed
246- fp = open (self ._file_path , "r " )
246+ fp = open (self ._file_path , "rb " )
247247 stream = fp
248248 try :
249+ raise Exception ()
249250 stream = mmap .mmap (fp .fileno (), 0 , access = mmap .ACCESS_READ )
250251 except Exception :
251252 pass
@@ -254,7 +255,12 @@ def _set_cache_(self, attr):
254255 try :
255256 self ._read_from_stream (stream )
256257 finally :
257- fp .close ()
258+ pass
259+ # make sure we close the stream ( possibly an mmap )
260+ # and the file
261+ #stream.close()
262+ #if stream is not fp:
263+ # fp.close()
258264 # END read from default index on demand
259265 else :
260266 super (IndexFile , self )._set_cache_ (attr )
@@ -603,7 +609,7 @@ def _to_relative_path(self, path):
603609 """
604610 if not os .path .isabs (path ):
605611 return path
606- relative_path = path .replace (self .repo .git .git_dir + "/" , "" )
612+ relative_path = path .replace (self .repo .git .git_dir + os . sep , "" )
607613 if relative_path == path :
608614 raise ValueError ("Absolute path %r is not in git repository at %r" % (path ,self .repo .git .git_dir ))
609615 return relative_path
@@ -839,10 +845,10 @@ def commit(self, message, parent_commits=None, head=True):
839845
840846 # create message stream
841847 tmp_file_path = tempfile .mktemp ()
842- fp = open (tmp_file_path ,"w " )
848+ fp = open (tmp_file_path ,"wb " )
843849 fp .write (str (message ))
844850 fp .close ()
845- fp = open (tmp_file_path ,"r " )
851+ fp = open (tmp_file_path ,"rb " )
846852 fp .seek (0 )
847853
848854 try :
0 commit comments