From 15b70418de50048d8d6235da78e401bcecf03d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 20 Apr 2020 16:13:23 +0100 Subject: [PATCH] Suppress errors for `os.makedirs()`, again. This is a bit more nuanced in Python 3, where only EEXIST errors are suppressed, to match the `delete` codepath. --- cachecontrol/caches/file_cache.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cachecontrol/caches/file_cache.py b/cachecontrol/caches/file_cache.py index de4e79bd..523b07a5 100644 --- a/cachecontrol/caches/file_cache.py +++ b/cachecontrol/caches/file_cache.py @@ -15,7 +15,7 @@ except NameError: # py2.X FileNotFoundError = (IOError, OSError) - + FileExistsError = (IOError, OSError) logger = logging.getLogger(__name__) @@ -130,10 +130,8 @@ def set(self, key, value): parentdir = os.path.dirname(name) try: os.makedirs(parentdir, self.dirmode) - except (IOError, OSError): - logging.debug( - "Error trying to create directory '%s'", parentdir, exc_info=True - ) + except FileExistsError: + pass with self.lock_class(name) as lock: # Write our actual file