We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9081bbd commit 4c71d22Copy full SHA for 4c71d22
Lib/test/support/os_helper.py
@@ -463,7 +463,10 @@ def create_empty_file(filename):
463
def open_dir_fd(path):
464
"""Open a file descriptor to a directory."""
465
assert os.path.isdir(path)
466
- dir_fd = os.open(path, os.O_RDONLY)
+ flags = os.O_RDONLY
467
+ if hasattr(os, "O_DIRECTORY"):
468
+ flags |= os.O_DIRECTORY
469
+ dir_fd = os.open(path, flags)
470
try:
471
yield dir_fd
472
finally:
Lib/test/test_os.py
@@ -3993,7 +3993,7 @@ class PathTConverterTests(unittest.TestCase):
3993
('access', False, (os.F_OK,), None),
3994
('chflags', False, (0,), None),
3995
('lchflags', False, (0,), None),
3996
- ('open', False, (0,), getattr(os, 'close', None)),
+ ('open', False, (os.O_RDONLY,), getattr(os, 'close', None)),
3997
]
3998
3999
def test_path_t_converter(self):
@@ -4365,6 +4365,7 @@ def test_fd(self):
4365
st = os.stat(entry.name, dir_fd=fd, follow_symlinks=False)
4366
self.assertEqual(entry.stat(follow_symlinks=False), st)
4367
4368
+ @unittest.skipIf(support.is_wasi, "WASI maps '' to cwd")
4369
def test_empty_path(self):
4370
self.assertRaises(FileNotFoundError, os.scandir, '')
4371
Tools/wasm/README.md
@@ -235,6 +235,9 @@ are:
235
call read/write/accept on a file descriptor that is passed into the process.
236
- ``socket.gethostname()`` and host name resolution APIs like
237
``socket.gethostbyname()`` are not implemented and always fail.
238
+- ``open(2)`` checks flags more strictly. Caller must pass either
239
+ ``O_RDONLY``, ``O_RDWR``, or ``O_WDONLY`` to ``os.open``. Directory file
240
+ descriptors must be created with flags ``O_RDONLY | O_DIRECTORY``.
241
- ``chmod(2)`` is not available. It's not possible to modify file permissions,
242
yet. A future version of WASI may provide a limited ``set_permissions`` API.
243
- User/group related features like ``os.chown()``, ``os.getuid``, etc. are
0 commit comments