Skip to content

Commit

Permalink
Suppress errors for os.makedirs(), again.
Browse files Browse the repository at this point in the history
This is a bit more nuanced in Python 3, where only EEXIST errors are
suppressed, to match the `delete` codepath.
  • Loading branch information
Flameeyes committed Jun 25, 2020
1 parent f75db54 commit 15b7041
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cachecontrol/caches/file_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
except NameError:
# py2.X
FileNotFoundError = (IOError, OSError)

FileExistsError = (IOError, OSError)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 15b7041

Please sign in to comment.