[issue46916] There is a problem with escape characters in the path passed in by pathlib.Path.mkdir()

Vincent FUNG report at bugs.python.org
Thu Mar 3 17:58:43 EST 2022


Vincent FUNG <vincent201399 at gmail.com> added the comment:

This problem occurs when the directory starts with 't', but works with os.makedirs(e) or macOS.

>>> e = Path(r'F:\ceven\test2')
>>> e.mkdir()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python310\lib\pathlib.py", line 1173, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'F:\\ceven\\test2'
>>> os.makedirs(e)



Another question about \t:

If a directory is passed as a parameter it will not be possible to use the parameter as a raw string. os.makedirs gives the same error whether it's r'%s' or repr().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46916>
_______________________________________


More information about the Python-bugs-list mailing list