Message376312
It consistently fails on the first directory in a long-path UNC notation server-folder.
>>> os.makedirs(r"\\?\UNC\DiskStation\already_exists", exist_ok=True)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 223, in makedirs
mkdir(name, mode)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\\\\?\\UNC\\'
>>> os.makedirs(r"\\?\UNC\DiskStation\already_exists")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 223, in makedirs
mkdir(name, mode)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\\\\?\\UNC\\'
The second level directory is working correctly as expected:
>>> os.makedirs(r"\\?\UNC\DiskStation\already_exists\new")
>>> os.makedirs(r"\\?\UNC\DiskStation\already_exists\new")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\safihre\AppData\Local\Programs\Python\Python38\lib\os.py", line 223, in makedirs
mkdir(name, mode)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: '\\\\?\\UNC\\DiskStation\\test_get2\\test2'
Inspecting the code, I think the problem is in the os.path.exists function that is called from within os.makedirs, the line in os.makedirs says:
if head and tail and not path.exists(head):
But:
>>> head, tail = path.split(r"\\?\UNC\DiskStation\already_exists")
('\\\\?\\UNC\\DiskStation', 'already_exists')
>>> os.path.exists(r'\\?\UNC\DiskStation')
False
>>> os.path.exists(r'\\DiskStation')
False
So it wrongly goes ahead and tries to create \\?\UNC\DiskStation |
|
Date |
User |
Action |
Args |
2020-09-03 19:28:37 | Safihre | set | recipients:
+ Safihre, paul.moore, tim.golden, zach.ware, steve.dower |
2020-09-03 19:28:37 | Safihre | set | messageid: <1599161317.94.0.39054668985.issue41705@roundup.psfhosted.org> |
2020-09-03 19:28:37 | Safihre | link | issue41705 messages |
2020-09-03 19:28:37 | Safihre | create | |
|