From 8034c1c48c49e5ac49649051e053d4b84dd02f86 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 25 Feb 2022 21:37:36 +0100 Subject: [PATCH] stdlib: shutil.chown does not work on Windows (#7384) --- stdlib/shutil.pyi | 20 ++++++++++++-------- tests/stubtest_allowlists/win32.txt | 3 +++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 752cf2cb5..55c964fbd 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -100,14 +100,18 @@ class _ntuple_diskusage(NamedTuple): free: int def disk_usage(path: int | StrOrBytesPath) -> _ntuple_diskusage: ... -@overload -def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ... -@overload -def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ... -@overload -def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ... -@overload -def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ... + +if sys.platform != "win32": + # while chown can be imported on Windows it doesn't actually work + # see https://bugs.python.org/issue33140 + @overload + def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ... + @overload + def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ... + @overload + def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ... + @overload + def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ... if sys.version_info >= (3, 8): @overload diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index ec7c2a84c..f7d68a3a0 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -75,3 +75,6 @@ ssl.SSLSocket.recvmsg ssl.SSLSocket.recvmsg_into ssl.SSLSocket.sendmsg winreg.HKEYType.handle + +# exist but do not work on Windows +shutil.chown