From d8de5cfd20aeda552616db798585ed3d6f108710 Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Mon, 7 Mar 2016 22:32:01 -0300 Subject: [PATCH] #439 & #447: Remove cache if created with unavailable db When switching between Python versions, the database package used to create the cache might be unavailable and an ImportError is raised, such as `ImportError: No module named gdbm`. --- thefuck/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thefuck/utils.py b/thefuck/utils.py index b1bbd42d..3089661e 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -228,8 +228,8 @@ def cache(*depends_on): value = fn(*args, **kwargs) db[key] = {'etag': etag, 'value': value} return value - except shelve_open_error: - # Caused when going from Python 2 to Python 3 and vice-versa + except (shelve_open_error, ImportError): + # Caused when switching between Python versions warn("Removing possibly out-dated cache") os.remove(cache_path)