Commits

Jurko Gospodnetić committed ee790ea

Cache files now stored in binary instead of text mode.

Python 3 raises an exception if you attempt to write a bytes object to a file
for text output. Current FileCache implementation catches that exception, logs
the problem and leaves behind an incomplete file. Then later on, reading that
cache file will fail, effectively disabling all file caching when using Python
3. Such failures occur inside Python pickling C code which may cause the whole
Python interpreter process to terminate abruptly in debug Python builds.

  • Participants
  • Parent commits 8e04868
  • Branches Python 3 support

Comments (0)

Files changed (1)

     def put(self, id, bfr):
         try:
             fn = self.__fn(id)
-            f = self.open(fn, 'w')
+            f = self.open(fn, 'wb')
             f.write(bfr)
             f.close()
             return bfr
     def putf(self, id, fp):
         try:
             fn = self.__fn(id)
-            f = self.open(fn, 'w')
+            f = self.open(fn, 'wb')
             f.write(fp.read())
             fp.close()
             f.close()
         try:
             fn = self.__fn(id)
             self.validate(fn)
-            return self.open(fn)
+            return self.open(fn, 'rb')
         except:
             pass
 
                 raise Exception()
         except:
             self.clear()
-            f = self.open(path, 'w')
+            f = self.open(path, 'wb')
             f.write(suds.__version__)
             f.close()