From 2bd06a0a3dd0a37127484e3b543c232cc0fc3577 Mon Sep 17 00:00:00 2001 From: layday <31134424+layday@users.noreply.github.com> Date: Sun, 5 Jan 2020 17:38:16 +0200 Subject: [PATCH] Restrict shutil.move src argument to str (#3559) See https://bugs.python.org/issue32689. This bug only affects `src`s which are directory Paths in Python 3.5 to 3.8 inclusive. Comes at the cost of restricting `src` to str even where a Path would work but this might be preferable to exposing the bug. --- stdlib/2and3/shutil.pyi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/shutil.pyi b/stdlib/2and3/shutil.pyi index a6ae9c588..cbf707175 100644 --- a/stdlib/2and3/shutil.pyi +++ b/stdlib/2and3/shutil.pyi @@ -102,10 +102,15 @@ else: def rmtree(path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ... -if sys.version_info >= (3, 5): - _CopyFn = Union[Callable[[str, str], None], Callable[[_Path, _Path], None]] +_CopyFn = Union[Callable[[str, str], None], Callable[[_Path, _Path], None]] + +if sys.version_info >= (3, 9): def move(src: _Path, dst: _Path, copy_function: _CopyFn = ...) -> _PathReturn: ... +elif sys.version_info >= (3, 5): + # See https://bugs.python.org/issue32689 + def move(src: str, dst: _Path, + copy_function: _CopyFn = ...) -> _PathReturn: ... else: def move(src: _Path, dst: _Path) -> _PathReturn: ...