Skip to content

Commit 8440125

Browse files
[3.11] gh-117127: glob tests: Reopen dir_fd to pick up directory changes (GH-117128) (GH-117149)
gh-117127: glob tests: Reopen dir_fd to pick up directory changes (GH-117128) (cherry picked from commit 42ae924) Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent 51da1dd commit 8440125

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Lib/test/test_glob.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def setUp(self):
4040
os.symlink(self.norm('broken'), self.norm('sym1'))
4141
os.symlink('broken', self.norm('sym2'))
4242
os.symlink(os.path.join('a', 'bcd'), self.norm('sym3'))
43+
self.open_dirfd()
44+
45+
def open_dirfd(self):
46+
if self.dir_fd is not None:
47+
os.close(self.dir_fd)
4348
if {os.open, os.stat} <= os.supports_dir_fd and os.scandir in os.supports_fd:
4449
self.dir_fd = os.open(self.tempdir, os.O_RDONLY | os.O_DIRECTORY)
4550
else:
@@ -349,6 +354,10 @@ def test_glob_non_directory(self):
349354
def test_glob_named_pipe(self):
350355
path = os.path.join(self.tempdir, 'mypipe')
351356
os.mkfifo(path)
357+
358+
# gh-117127: Reopen self.dir_fd to pick up directory changes
359+
self.open_dirfd()
360+
352361
self.assertEqual(self.rglob('mypipe'), [path])
353362
self.assertEqual(self.rglob('mypipe*'), [path])
354363
self.assertEqual(self.rglob('mypipe', ''), [])

0 commit comments

Comments
 (0)