From 3f7638b46187e73a6604f1f12dcc9a19e0aecb7d Mon Sep 17 00:00:00 2001 From: Deshdeepak Date: Fri, 18 Aug 2023 00:55:44 +0530 Subject: [PATCH] Update os.py (#175) * Update os.py Check if os provides link * Add a changelog entry - os.link check --- README.md | 2 ++ src/aiofiles/os.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 04f327b..45bb554 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ async def test_stuff(): #### 23.2.2 (UNRELEASED) +- Import `os.link` conditionally to fix importing on android. + [#175](https://github.com/Tinche/aiofiles/issues/175) - Remove spurious items from `aiofiles.os.__all__` when running on Windows. #### 23.2.1 (2023-08-09) diff --git a/src/aiofiles/os.py b/src/aiofiles/os.py index 154328f..16ff875 100644 --- a/src/aiofiles/os.py +++ b/src/aiofiles/os.py @@ -16,7 +16,6 @@ "makedirs", "rmdir", "removedirs", - "link", "symlink", "readlink", "listdir", @@ -24,6 +23,8 @@ "access", "wrap", ] +if hasattr(os, "link"): + __all__ += ["link"] if hasattr(os, "sendfile"): __all__ += ["sendfile"] if hasattr(os, "statvfs"): @@ -40,13 +41,14 @@ makedirs = wrap(os.makedirs) rmdir = wrap(os.rmdir) removedirs = wrap(os.removedirs) -link = wrap(os.link) symlink = wrap(os.symlink) readlink = wrap(os.readlink) listdir = wrap(os.listdir) scandir = wrap(os.scandir) access = wrap(os.access) +if hasattr(os, "link"): + link = wrap(os.link) if hasattr(os, "sendfile"): sendfile = wrap(os.sendfile) if hasattr(os, "statvfs"):