Skip to content

Add platform checks for various sys values #4137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions stdlib/3/sys.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]]

# ----- sys variables -----
abiflags: str
if sys.platform != "win32":
abiflags: str
argv: List[str]
base_exec_prefix: str
base_prefix: str
byteorder: str
builtin_module_names: Sequence[str] # actually a tuple of strings
copyright: str
# dllhandle = 0 # Windows only
if sys.platform == "win32":
dllhandle: int
dont_write_bytecode: bool
displayhook: Callable[[object], Any]
excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any]
Expand Down Expand Up @@ -64,7 +66,8 @@ api_version: int
warnoptions: Any
# Each entry is a tuple of the form (action, message, category, module,
# lineno)
# winver = '' # Windows only
if sys.platform == "win32":
winver: str
_xoptions: Dict[Any, Any]


Expand Down Expand Up @@ -141,7 +144,6 @@ def exc_info() -> _OptExcInfo: ...
def exit(__status: object = ...) -> NoReturn: ...
def getdefaultencoding() -> str: ...
if sys.platform != 'win32':
# Unix only
def getdlopenflags() -> int: ...
def getfilesystemencoding() -> str: ...
def getrefcount(__object: Any) -> int: ...
Expand Down Expand Up @@ -179,8 +181,8 @@ class _WinVersion(Tuple[int, int, int, int,
product_type: int
platform_version: Tuple[int, int, int]


def getwindowsversion() -> _WinVersion: ... # Windows only
if sys.platform == "win32":
def getwindowsversion() -> _WinVersion: ...

def intern(__string: str) -> str: ...

Expand All @@ -190,7 +192,8 @@ if sys.version_info >= (3, 7):
__breakpointhook__: Any # contains the original value of breakpointhook
def breakpointhook(*args: Any, **kwargs: Any) -> Any: ...

def setdlopenflags(__flags: int) -> None: ... # Linux only
if sys.platform != "win32":
def setdlopenflags(__flags: int) -> None: ...
def setrecursionlimit(__limit: int) -> None: ...
def setswitchinterval(__interval: float) -> None: ...

Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_whitelists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spwd.getspnam
spwd.struct_spwd._asdict
spwd.struct_spwd._make
spwd.struct_spwd._replace
sys.getwindowsversion
time.CLOCK_HIGHRES
urllib.request.proxy_bypass

Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_whitelists/win32.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ locale.nl_langinfo # Function that should be moved to _locale and re-exported c
os.path.join # Parameter name mismatch
posixpath.altsep # Type mismatch
posixpath.realpath # Parameter name mismatch
sys.abiflags # Not present
sys.setdlopenflags # Not present
urllib.request.pathname2url # Parameter name mismatch
urllib.request.url2pathname # Same

Expand Down