Show More
@@ -67,7 +67,8 b' class PickleShareDB(collections.MutableMapping):' | |||
|
67 | 67 | return self.cache[fil][0] |
|
68 | 68 | try: |
|
69 | 69 | # The cached item has expired, need to read |
|
70 |
|
|
|
70 | with fil.open("rb") as f: | |
|
71 | obj = pickle.loads(f.read()) | |
|
71 | 72 | except: |
|
72 | 73 | raise KeyError(key) |
|
73 | 74 | |
@@ -82,7 +83,8 b' class PickleShareDB(collections.MutableMapping):' | |||
|
82 | 83 | parent.makedirs() |
|
83 | 84 | # We specify protocol 2, so that we can mostly go between Python 2 |
|
84 | 85 | # and Python 3. We can upgrade to protocol 3 when Python 2 is obsolete. |
|
85 | pickled = pickle.dump(value,fil.open('wb'), protocol=2) | |
|
86 | with fil.open('wb') as f: | |
|
87 | pickled = pickle.dump(value, f, protocol=2) | |
|
86 | 88 | try: |
|
87 | 89 | self.cache[fil] = (value,fil.mtime) |
|
88 | 90 | except OSError,e: |
General Comments 0
You need to be logged in to leave comments.
Login now