[issue25803] pathlib.Path('/').mkdir() raises wrong error type

Eryk Sun report at bugs.python.org
Sat Dec 5 09:46:51 EST 2015


Eryk Sun added the comment:

The mkdir method needs a fix similar to what was done for issue 25583. For example, currently on Windows the exist_ok option doesn't handle the PermissionError raised when [accidentally] trying to create the root directory:

    >>> pathlib.Path('C:/').mkdir(exist_ok=True)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Program Files\Python 3.5\lib\pathlib.py", line 1199, in mkdir
        self._accessor.mkdir(self, mode)
      File "C:\Program Files\Python 3.5\lib\pathlib.py", line 371, in wrapped
        return strfunc(str(pathobj), *args)
    PermissionError: [WinError 5] Access is denied: 'C:\\'

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25803>
_______________________________________


More information about the Python-bugs-list mailing list