8000 GH-85633: Fix pathlib test failures on filesystems without world-write. · barneygale/cpython@3b3d975 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b3d975

Browse files
committed
pythonGH-85633: Fix pathlib test failures on filesystems without world-write.
Replace `umask(0)` with `umask(2)` so the created files are not world-writable, and replace `umask(0o022)` with `umask(0o026)` to check that permissions for 'others' can still be set.
1 parent 0fd97e4 commit 3b3d975

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,18 +1605,18 @@ def test_absolute_posix(self):
16051605
)
16061606
@needs_posix
16071607
def test_open_mode(self):
1608-
old_mask = os.umask(0)
1608+
old_mask = os.umask(2)
16091609
self.addCleanup(os.umask, old_mask)
16101610
p = self.cls(self.base)
16111611
with (p / 'new_file').open('wb'):
16121612
pass
16131613
st = os.stat(self.parser.join(self.base, 'new_file'))
1614-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o666)
1615-
os.umask(0o022)
1614+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o664)
1615+
os.umask(0o026)
16161616
with (p / 'other_new_file').open('wb'):
16171617
pass
16181618
st = os.stat(self.parser.join(self.base, 'other_new_file'))
1619-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o644)
1619+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o640)
16201620

16211621
@needs_posix
16221622
def test_resolve_root(self):
@@ -1634,16 +1634,16 @@ def test_resolve_root(self):
16341634
)
16351635
@needs_posix
16361636
def test_touch_mode(self):
1637-
old_mask = os.umask(0)
1637+
old_mask = os.umask(2)
16381638
self.addCleanup(os.umask, old_mask)
16391639
p = self.cls(self.base)
16401640
(p / 'new_file').touch()
16411641
st = os.stat(self.parser.join(self.base, 'new_file'))
1642-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o666)
1643-
os.umask(0o022)
1642+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o664)
1643+
os.umask(0o026)
16441644
(p / 'other_new_file').touch()
16451645
st = os.stat(self.parser.join(self.base, 'other_new_file'))
1646-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o644)
1646+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o640)
16471647
(p / 'masked_new_file').touch(mode=0o750)
16481648
st = os.stat(self.parser.join(self.base, 'masked_new_file'))
16491649
self.assertEqual(stat.S_IMODE(st.st_mode), 0o750)

0 commit comments

Comments
 (0)
0