Skip to content

Commit 5879e44

Browse files
committed
Address reviewer feedback
1 parent c46d777 commit 5879e44

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Lib/test/test_contextlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,23 +1400,23 @@ def test_original_path_too_long(self):
14001400
os.chdir('a')
14011401
count += 1
14021402

1403-
self.assertTrue(count > 0)
1403+
self.assertGreater(count, 0)
14041404
os.mkdir('a')
14051405
with chdir('a'):
1406-
self.assertTrue(len(os.getcwd()) > path_max)
1406+
self.assertGreater(len(os.getcwd()), path_max)
14071407

14081408
@unittest.skipUnless(chdir._supports_fd(),
14091409
"chdir requires fd support for deleted dir")
14101410
def test_original_path_deleted(self):
14111411
original = os.getcwd()
14121412
dir = tempfile.TemporaryDirectory()
1413+
self.addCleanup(dir.cleanup)
14131414
try:
14141415
os.chdir(dir.name)
14151416
with chdir(original):
14161417
dir.cleanup()
14171418
finally:
14181419
os.chdir(original)
1419-
dir.cleanup()
14201420

14211421

14221422
if __name__ == "__main__":
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Use fds in contextlib.chdir where supported. This fixes bugs if the original
2-
working directory is greater than PATH_MAX and/or is deleted before the
3-
context manager exits.
1+
Use file descriptors in :func:`contextlib.chdir` when possible to prevent
2+
issues when the original working directory is concurrently deleted or when its
3+
path length is longer than the maximum allowed by the host platform.

0 commit comments

Comments
 (0)