Skip to content

Commit

Permalink
In case of unpickling problems, raise a KeyError
Browse files Browse the repository at this point in the history
This will trigger a re-build of the questioned object.
  • Loading branch information
olebole committed Apr 12, 2022
1 parent 198f6bb commit 50abdfe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyraf/sqliteshelve.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ def __getitem__(self, key):
{'key': key})
result = cursor.fetchone()
if result:
return pickle.loads(result[0])
try:
return pickle.loads(result[0])
except ValueError:
# In case of unpickling problems, raise a KeyError
# so that the cache entry can be rebuilt.
raise KeyError(key)
else:
raise KeyError(key)
finally:
Expand Down

0 comments on commit 50abdfe

Please sign in to comment.