Subject: [PATCH] Fixed Path.copy() and Path.copy_info failing on Python 3.14.0a7

From: Alex Grönholm <[email-masked]>
Date: Tue, 15 Apr 2025 00:54:22 +0300

---
 docs/versionhistory.rst    | 1 +
 src/anyio/_core/_fileio.py | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/anyio/_core/_fileio.py b/src/anyio/_core/_fileio.py
index 17459b79..2eae029e 100644
--- a/src/anyio/_core/_fileio.py
+++ b/src/anyio/_core/_fileio.py
@@ -428,7 +428,7 @@ async def copy(
                 follow_symlinks=follow_symlinks,
                 preserve_metadata=preserve_metadata,
             )
-            return Path(await to_thread.run_sync(func, target))
+            return Path(await to_thread.run_sync(func, pathlib.Path(target)))
 
         async def copy_into(
             self,
@@ -442,7 +442,7 @@ async def copy_into(
                 follow_symlinks=follow_symlinks,
                 preserve_metadata=preserve_metadata,
             )
-            return Path(await to_thread.run_sync(func, target_dir))
+            return Path(await to_thread.run_sync(func, pathlib.Path(target_dir)))
 
         async def move(self, target: str | os.PathLike[str]) -> Path:
             # Upstream does not handle anyio.Path properly as a PathLike