Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5f68511

Browse filesBrowse files
authored
GH-85633: Fix pathlib test failures on filesystems without world-write. (#122883)
Replace `umask(0)` with `umask(0o002)` 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 901d949 commit 5f68511
Copy full SHA for 5f68511

File tree

Expand file treeCollapse file tree

1 file changed

+12
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-8
lines changed

‎Lib/test/test_pathlib/test_pathlib.py

Copy file name to clipboardExpand all lines: Lib/test/test_pathlib/test_pathlib.py
+12-8Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,18 +1605,20 @@ def test_absolute_posix(self):
16051605
)
16061606
@needs_posix
16071607
def test_open_mode(self):
1608-
old_mask = os.umask(0)
1608+
# Unmask all permissions except world-write, which may
1609+
# not be supported on some filesystems (see GH-85633.)
1610+
old_mask = os.umask(0o002)
16091611
self.addCleanup(os.umask, old_mask)
16101612
p = self.cls(self.base)
16111613
with (p / 'new_file').open('wb'):
16121614
pass
16131615
st = os.stat(self.parser.join(self.base, 'new_file'))
1614-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o666)
1615-
os.umask(0o022)
1616+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o664)
1617+
os.umask(0o026)
16161618
with (p / 'other_new_file').open('wb'):
16171619
pass
16181620
st = os.stat(self.parser.join(self.base, 'other_new_file'))
1619-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o644)
1621+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o640)
16201622

16211623
@needs_posix
16221624
def test_resolve_root(self):
@@ -1634,16 +1636,18 @@ def test_resolve_root(self):
16341636
)
16351637
@needs_posix
16361638
def test_touch_mode(self):
1637-
old_mask = os.umask(0)
1639+
# Unmask all permissions except world-write, which may
1640+
# not be supported on some filesystems (see GH-85633.)
1641+
old_mask = os.umask(0o002)
16381642
self.addCleanup(os.umask, old_mask)
16391643
p = self.cls(self.base)
16401644
(p / 'new_file').touch()
16411645
st = os.stat(self.parser.join(self.base, 'new_file'))
1642-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o666)
1643-
os.umask(0o022)
1646+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o664)
1647+
os.umask(0o026)
16441648
(p / 'other_new_file').touch()
16451649
st = os.stat(self.parser.join(self.base, 'other_new_file'))
1646-
self.assertEqual(stat.S_IMODE(st.st_mode), 0o644)
1650+
self.assertEqual(stat.S_IMODE(st.st_mode), 0o640)
16471651
(p / 'masked_new_file').touch(mode=0o750)
16481652
st = os.stat(self.parser.join(self.base, 'masked_new_file'))
16491653
self.assertEqual(stat.S_IMODE(st.st_mode), 0o750)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.