modernize some modules' code by replacing OSError->ENOENT/ENOTDIR/EPERM/EEXIST occurrences with the corresponding pep-3151 exceptions (FileNotFoundError, NotADirectoryError, etc.)

This commit is contained in:
Giampaolo Rodola' 2013-02-12 15:14:17 +01:00
parent b071d4f3da
commit 0166a283f6
6 changed files with 27 additions and 51 deletions

View file

@ -232,10 +232,9 @@ def makedirs(name, mode=0o777, exist_ok=False):
if head and tail and not path.exists(head):
try:
makedirs(head, mode, exist_ok)
except OSError as e:
except FileExistsError:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
pass
cdir = curdir
if isinstance(tail, bytes):
cdir = bytes(curdir, 'ASCII')