mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
Merge pull request #458 from scorphus/anydbm
#439 #447 Except anydbm instead of gdbm for PY2
This commit is contained in:
commit
ce959b2a8b
@ -1,4 +1,3 @@
|
||||
import dbm
|
||||
import os
|
||||
import pickle
|
||||
import pkg_resources
|
||||
@ -16,10 +15,12 @@ from warnings import warn
|
||||
|
||||
DEVNULL = open(os.devnull, 'w')
|
||||
|
||||
shelve_open_errors = (dbm.error, )
|
||||
if six.PY2:
|
||||
import gdbm
|
||||
shelve_open_errors += (gdbm.error, )
|
||||
import anydbm
|
||||
shelve_open_error = anydbm.error
|
||||
else:
|
||||
import dbm
|
||||
shelve_open_error = dbm.error
|
||||
|
||||
|
||||
def memoize(fn):
|
||||
@ -227,7 +228,7 @@ def cache(*depends_on):
|
||||
value = fn(*args, **kwargs)
|
||||
db[key] = {'etag': etag, 'value': value}
|
||||
return value
|
||||
except shelve_open_errors:
|
||||
except shelve_open_error:
|
||||
# Caused when going from Python 2 to Python 3 and vice-versa
|
||||
warn("Removing possibly out-dated cache")
|
||||
os.remove(cache_path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user