mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-90473: WASI requires proper open(2) flags (GH-93529)
This commit is contained in:
parent
9081bbd036
commit
4c71d22c4f
3 changed files with 9 additions and 2 deletions
|
@ -463,7 +463,10 @@ def create_empty_file(filename):
|
|||
def open_dir_fd(path):
|
||||
"""Open a file descriptor to a directory."""
|
||||
assert os.path.isdir(path)
|
||||
dir_fd = os.open(path, os.O_RDONLY)
|
||||
flags = os.O_RDONLY
|
||||
if hasattr(os, "O_DIRECTORY"):
|
||||
flags |= os.O_DIRECTORY
|
||||
dir_fd = os.open(path, flags)
|
||||
try:
|
||||
yield dir_fd
|
||||
finally:
|
||||
|
|
|
@ -3993,7 +3993,7 @@ class PathTConverterTests(unittest.TestCase):
|
|||
('access', False, (os.F_OK,), None),
|
||||
('chflags', False, (0,), None),
|
||||
('lchflags', False, (0,), None),
|
||||
('open', False, (0,), getattr(os, 'close', None)),
|
||||
('open', False, (os.O_RDONLY,), getattr(os, 'close', None)),
|
||||
]
|
||||
|
||||
def test_path_t_converter(self):
|
||||
|
@ -4365,6 +4365,7 @@ class TestScandir(unittest.TestCase):
|
|||
st = os.stat(entry.name, dir_fd=fd, follow_symlinks=False)
|
||||
self.assertEqual(entry.stat(follow_symlinks=False), st)
|
||||
|
||||
@unittest.skipIf(support.is_wasi, "WASI maps '' to cwd")
|
||||
def test_empty_path(self):
|
||||
self.assertRaises(FileNotFoundError, os.scandir, '')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue