Skip to content

Commit

Permalink
Add stubs for nt (#10917)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Oct 19, 2023
1 parent 21fcd89 commit b964000
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ multiprocessing.shared_memory: 3.8-
netrc: 2.7-
nis: 2.7-
nntplib: 2.7-
nt: 2.7-
ntpath: 2.7-
nturl2path: 2.7-
numbers: 2.7-
Expand Down
111 changes: 111 additions & 0 deletions stdlib/nt.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import sys

if sys.platform == "win32":
# Actually defined here and re-exported from os at runtime,
# but this leads to less code duplication
from os import (
F_OK as F_OK,
O_APPEND as O_APPEND,
O_BINARY as O_BINARY,
O_CREAT as O_CREAT,
O_EXCL as O_EXCL,
O_NOINHERIT as O_NOINHERIT,
O_RANDOM as O_RANDOM,
O_RDONLY as O_RDONLY,
O_RDWR as O_RDWR,
O_SEQUENTIAL as O_SEQUENTIAL,
O_SHORT_LIVED as O_SHORT_LIVED,
O_TEMPORARY as O_TEMPORARY,
O_TEXT as O_TEXT,
O_TRUNC as O_TRUNC,
O_WRONLY as O_WRONLY,
P_DETACH as P_DETACH,
P_NOWAIT as P_NOWAIT,
P_NOWAITO as P_NOWAITO,
P_OVERLAY as P_OVERLAY,
P_WAIT as P_WAIT,
R_OK as R_OK,
TMP_MAX as TMP_MAX,
W_OK as W_OK,
X_OK as X_OK,
DirEntry as DirEntry,
abort as abort,
access as access,
chdir as chdir,
chmod as chmod,
close as close,
closerange as closerange,
cpu_count as cpu_count,
device_encoding as device_encoding,
dup as dup,
dup2 as dup2,
error as error,
execv as execv,
execve as execve,
fspath as fspath,
fstat as fstat,
fsync as fsync,
ftruncate as ftruncate,
get_handle_inheritable as get_handle_inheritable,
get_inheritable as get_inheritable,
get_terminal_size as get_terminal_size,
getcwd as getcwd,
getcwdb as getcwdb,
getlogin as getlogin,
getpid as getpid,
getppid as getppid,
isatty as isatty,
kill as kill,
link as link,
listdir as listdir,
lseek as lseek,
lstat as lstat,
mkdir as mkdir,
open as open,
pipe as pipe,
putenv as putenv,
read as read,
readlink as readlink,
remove as remove,
rename as rename,
replace as replace,
rmdir as rmdir,
scandir as scandir,
set_handle_inheritable as set_handle_inheritable,
set_inheritable as set_inheritable,
spawnv as spawnv,
spawnve as spawnve,
startfile as startfile,
stat as stat,
stat_result as stat_result,
statvfs_result as statvfs_result,
strerror as strerror,
symlink as symlink,
system as system,
terminal_size as terminal_size,
times as times,
times_result as times_result,
truncate as truncate,
umask as umask,
uname_result as uname_result,
unlink as unlink,
urandom as urandom,
utime as utime,
waitpid as waitpid,
write as write,
)

if sys.version_info >= (3, 9):
from os import unsetenv as unsetenv, waitstatus_to_exitcode as waitstatus_to_exitcode
if sys.version_info >= (3, 11):
from os import EX_OK as EX_OK
if sys.version_info >= (3, 12):
from os import (
get_blocking as get_blocking,
listdrives as listdrives,
listmounts as listmounts,
listvolumes as listvolumes,
set_blocking as set_blocking,
)

environ: dict[str, str]
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ asyncio.windows_events
asyncio.windows_utils
msilib(.[a-z]+)?
msvcrt
nt
winreg
winsound
ossaudiodev
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ asyncio.windows_events
asyncio.windows_utils
msilib(.[a-z]+)?
msvcrt
nt
winreg
winsound

Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/win32.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ multiprocessing.reduction.AbstractReducer.DupHandle
# Exists at runtime, but missing from stubs
encodings.mbcs
encodings.oem
nt
_winapi.CreateFileMapping
_winapi.MapViewOfFile
_winapi.OpenFileMapping
Expand Down

0 comments on commit b964000

Please sign in to comment.