Issue #29416: Prevent infinite loop in pathlib.Path.mkdir · python/cpython@1add96f · GitHub
Skip to content

Commit 1add96f

Browse files
committed
Issue #29416: Prevent infinite loop in pathlib.Path.mkdir
2 parents 86e4237 + d3c4853 commit 1add96f

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

Lib/pathlib.py

Lines changed: 1 addition & 1 deletion

Lib/test/test_pathlib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,17 @@ 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+
@only_nt # XXX: not sure how to test this on POSIX
1780+
def test_mkdir_with_unknown_drive(self):
1781+
for d in 'ZYXWVUTSRQPONMLKJIHGFEDCBA':
1782+
p = self.cls(d + ':\\')
1783+
if not p.is_dir():
1784+
break
1785+
else:
1786+
self.skipTest("cannot find a drive that doesn't exist")
1787+
with self.assertRaises(OSError):
1788+
(p / 'child' / 'path').mkdir(parents=True)
1789+
17791790
def test_mkdir_with_child_file(self):
17801791
p = self.cls(BASE, 'dirB', 'fileB')
17811792
self.assertTrue(p.exists())

Misc/NEWS

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)