Browse Source

Open the cache in binary mode.

This fixes an issue where the cache fails to load on Windows machines.
EOL characters were getting modified, causing zlib uncompression to fail.

[hoxu@users.sf.net: slightly modified the commit message]

Signed-off-by: Heikki Hokkanen <hoxu@users.sf.net>
Tyler Nielsen 15 years ago
parent
commit
1dd89a2322
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      gitstats

+ 2
- 2
gitstats View File

87
 		if not os.path.exists(cachefile):
87
 		if not os.path.exists(cachefile):
88
 			return
88
 			return
89
 		print 'Loading cache...'
89
 		print 'Loading cache...'
90
-		f = open(cachefile)
90
+		f = open(cachefile, 'rb')
91
 		try:
91
 		try:
92
 			self.cache = pickle.loads(zlib.decompress(f.read()))
92
 			self.cache = pickle.loads(zlib.decompress(f.read()))
93
 		except:
93
 		except:
149
 	# Save cacheable data
149
 	# Save cacheable data
150
 	def saveCache(self, cachefile):
150
 	def saveCache(self, cachefile):
151
 		print 'Saving cache...'
151
 		print 'Saving cache...'
152
-		f = open(cachefile, 'w')
152
+		f = open(cachefile, 'wb')
153
 		#pickle.dump(self.cache, f)
153
 		#pickle.dump(self.cache, f)
154
 		data = zlib.compress(pickle.dumps(self.cache))
154
 		data = zlib.compress(pickle.dumps(self.cache))
155
 		f.write(data)
155
 		f.write(data)