mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-90473: WASI requires proper open(2) flags (GH-93529)
(cherry picked from commit 4c71d22c4f
)
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
a848a9894d
commit
20be4a11fe
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue