From 3cc49408426a9d431c9a3f518e5bc8c3a1f53a46 Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Sun, 14 Feb 2016 00:26:51 -0200 Subject: [PATCH] #439 #447 Except anydbm instead of gdbm for PY2 Fix #439 and close #447 --- thefuck/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/thefuck/utils.py b/thefuck/utils.py index 047dcc88..b1bbd42d 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -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)