Make os.fchdir, os.fsync, and os.fdatasync accept FileDescriptorLike (#4544)

For the fd passed to these functions, CPython accepts not just an int,
but also anything with a fileno() method.

Fixes #4539
This commit is contained in:
Cebtenzzre
2020-09-15 19:30:34 -04:00
committed by GitHub
parent d402f55334
commit 1334840323
3 changed files with 20 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
from _typeshed import FileDescriptorLike
from typing import IO, AnyStr, Dict, List, Mapping, NamedTuple, Optional, Sequence, Tuple, TypeVar, Union
error = OSError
@@ -105,17 +106,17 @@ def dup(fd: int) -> int: ...
def dup2(fd: int, fd2: int) -> None: ...
def execv(path: str, args: Sequence[str], env: Mapping[str, str]) -> None: ...
def execve(path: str, args: Sequence[str], env: Mapping[str, str]) -> None: ...
def fchdir(fd: int) -> None: ...
def fchdir(fd: FileDescriptorLike) -> None: ...
def fchmod(fd: int, mode: int) -> None: ...
def fchown(fd: int, uid: int, gid: int) -> None: ...
def fdatasync(fd: int) -> None: ...
def fdatasync(fd: FileDescriptorLike) -> None: ...
def fdopen(fd: int, mode: str = ..., bufsize: int = ...) -> IO[str]: ...
def fork() -> int: ...
def forkpty() -> Tuple[int, int]: ...
def fpathconf(fd: int, name: str) -> None: ...
def fstat(fd: int) -> stat_result: ...
def fstatvfs(fd: int) -> statvfs_result: ...
def fsync(fd: int) -> None: ...
def fsync(fd: FileDescriptorLike) -> None: ...
def ftruncate(fd: int, length: int) -> None: ...
def getcwd() -> str: ...
def getcwdu() -> unicode: ...