Skip to content

Commit 8034c1c

Browse files
not-my-profileJelleZijlstra
authored andcommitted
stdlib: shutil.chown does not work on Windows (#7384)
1 parent d63dc4b commit 8034c1c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

stdlib/shutil.pyi

+12-8
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,18 @@ class _ntuple_diskusage(NamedTuple):
100100
free: int
101101

102102
def disk_usage(path: int | StrOrBytesPath) -> _ntuple_diskusage: ...
103-
@overload
104-
def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ...
105-
@overload
106-
def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ...
107-
@overload
108-
def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ...
109-
@overload
110-
def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ...
103+
104+
if sys.platform != "win32":
105+
# while chown can be imported on Windows it doesn't actually work
106+
# see https://bugs.python.org/issue33140
107+
@overload
108+
def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ...
109+
@overload
110+
def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ...
111+
@overload
112+
def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ...
113+
@overload
114+
def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ...
111115

112116
if sys.version_info >= (3, 8):
113117
@overload

tests/stubtest_allowlists/win32.txt

+3
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ ssl.SSLSocket.recvmsg
7575
ssl.SSLSocket.recvmsg_into
7676
ssl.SSLSocket.sendmsg
7777
winreg.HKEYType.handle
78+
79+
# exist but do not work on Windows
80+
shutil.chown

0 commit comments

Comments
 (0)