@@ -503,11 +503,14 @@ if sys.platform != "win32":
503
503
def getenvb (key : bytes ) -> bytes | None : ...
504
504
@overload
505
505
def getenvb (key : bytes , default : _T ) -> bytes | _T : ...
506
+ def putenv (__name : StrOrBytesPath , __value : StrOrBytesPath ) -> None : ...
507
+ def unsetenv (__name : StrOrBytesPath ) -> None : ...
506
508
507
- def putenv (__name : bytes | str , __value : bytes | str ) -> None : ...
509
+ else :
510
+ def putenv (__name : str , __value : str ) -> None : ...
508
511
509
- if sys . platform != "win32" or sys .version_info >= (3 , 9 ):
510
- def unsetenv (__name : bytes | str ) -> None : ...
512
+ if sys .version_info >= (3 , 9 ):
513
+ def unsetenv (__name : str ) -> None : ...
511
514
512
515
_Opener : TypeAlias = Callable [[str , int ], int ]
513
516
@@ -622,7 +625,7 @@ if sys.platform != "win32":
622
625
def posix_fadvise (__fd : int , __offset : int , __length : int , __advice : int ) -> None : ...
623
626
624
627
def pread (__fd : int , __length : int , __offset : int ) -> bytes : ...
625
- def pwrite (__fd : int , __buffer : bytes , __offset : int ) -> int : ...
628
+ def pwrite (__fd : int , __buffer : ReadableBuffer , __offset : int ) -> int : ...
626
629
# In CI, stubtest sometimes reports that these are available on MacOS, sometimes not
627
630
def preadv (__fd : int , __buffers : SupportsLenAndGetItem [WriteableBuffer ], __offset : int , __flags : int = ...) -> int : ...
628
631
def pwritev (__fd : int , __buffers : SupportsLenAndGetItem [ReadableBuffer ], __offset : int , __flags : int = ...) -> int : ...
@@ -641,8 +644,8 @@ if sys.platform != "win32":
641
644
in_fd : int ,
642
645
offset : int ,
643
646
count : int ,
644
- headers : Sequence [bytes ] = ...,
645
- trailers : Sequence [bytes ] = ...,
647
+ headers : Sequence [ReadableBuffer ] = ...,
648
+ trailers : Sequence [ReadableBuffer ] = ...,
646
649
flags : int = ...,
647
650
) -> int : ... # FreeBSD and Mac OS X only
648
651
def readv (__fd : int , __buffers : SupportsLenAndGetItem [WriteableBuffer ]) -> int : ...
@@ -671,7 +674,7 @@ if sys.platform != "win32":
671
674
def tcsetpgrp (__fd : int , __pgid : int ) -> None : ...
672
675
def ttyname (__fd : int ) -> str : ...
673
676
674
- def write (__fd : int , __data : bytes ) -> int : ...
677
+ def write (__fd : int , __data : ReadableBuffer ) -> int : ...
675
678
def access (
676
679
path : _FdOrAnyPath , mode : int , * , dir_fd : int | None = ..., effective_ids : bool = ..., follow_symlinks : bool = ...
677
680
) -> bool : ...
@@ -775,14 +778,19 @@ if sys.platform != "win32":
775
778
) -> Iterator [tuple [str , list [str ], list [str ], int ]]: ...
776
779
@overload
777
780
def fwalk (
778
- top : bytes , topdown : bool = ..., onerror : _OnError | None = ..., * , follow_symlinks : bool = ..., dir_fd : int | None = ...
781
+ top : BytesPath ,
782
+ topdown : bool = ...,
783
+ onerror : _OnError | None = ...,
784
+ * ,
785
+ follow_symlinks : bool = ...,
786
+ dir_fd : int | None = ...,
779
787
) -> Iterator [tuple [bytes , list [bytes ], list [bytes ], int ]]: ...
780
788
if sys .platform == "linux" :
781
789
def getxattr (path : _FdOrAnyPath , attribute : StrOrBytesPath , * , follow_symlinks : bool = ...) -> bytes : ...
782
790
def listxattr (path : _FdOrAnyPath | None = ..., * , follow_symlinks : bool = ...) -> list [str ]: ...
783
791
def removexattr (path : _FdOrAnyPath , attribute : StrOrBytesPath , * , follow_symlinks : bool = ...) -> None : ...
784
792
def setxattr (
785
- path : _FdOrAnyPath , attribute : StrOrBytesPath , value : bytes , flags : int = ..., * , follow_symlinks : bool = ...
793
+ path : _FdOrAnyPath , attribute : StrOrBytesPath , value : ReadableBuffer , flags : int = ..., * , follow_symlinks : bool = ...
786
794
) -> None : ...
787
795
788
796
def abort () -> NoReturn : ...
@@ -810,6 +818,10 @@ _ExecVArgs: TypeAlias = (
810
818
| list [str | PathLike [Any ]]
811
819
| list [bytes | str | PathLike [Any ]]
812
820
)
821
+ # Depending on the OS, the keys and values are passed either to
822
+ # PyUnicode_FSDecoder (which accepts str | ReadableBuffer) or to
823
+ # PyUnicode_FSConverter (which accepts StrOrBytesPath). For simplicity,
824
+ # we limit to str | bytes.
813
825
_ExecEnv : TypeAlias = Mapping [bytes , bytes | str ] | Mapping [str , bytes | str ]
814
826
815
827
def execv (__path : StrOrBytesPath , __argv : _ExecVArgs ) -> NoReturn : ...
0 commit comments