bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True)… · python/cpython@af7b9ec · GitHub
Skip to content

Commit af7b9ec

Browse files
bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True) (#805)
when the OS gives priority to errors such as EACCES over EEXIST.
1 parent 8988945 commit af7b9ec

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

Lib/pathlib.py

Lines changed: 15 additions & 17 deletions

Lib/test/test_pathlib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,11 @@ def test_mkdir_exist_ok_with_parent(self):
17761776
self.assertTrue(p.exists())
17771777
self.assertEqual(p.stat().st_ctime, st_ctime_first)
17781778

1779+
def test_mkdir_exist_ok_root(self):
1780+
# Issue #25803: A drive root could raise PermissionError on Windows
1781+
self.cls('/').resolve().mkdir(exist_ok=True)
1782+
self.cls('/').resolve().mkdir(parents=True, exist_ok=True)
1783+
17791784
@only_nt # XXX: not sure how to test this on POSIX
17801785
def test_mkdir_with_unknown_drive(self):
17811786
for d in 'ZYXWVUTSRQPONMLKJIHGFEDCBA':

Misc/NEWS

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)