-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Update sys.pyi for Python3.12 #10245
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
Conversation
This comment has been minimized.
This comment has been minimized.
(Let's merge in #10253 first) |
This comment has been minimized.
This comment has been minimized.
Looks like you get to remove some allowlist entries :) |
stdlib/sys.pyi
Outdated
if sys.platform == "linux": | ||
def activate_stack_trampoline(__backend: str) -> None: ... | ||
def deactivate_stack_trampoline() -> None: ... | ||
def is_stack_trampoline_active() -> bool: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to stubtest, these exist on all platforms, not just Linux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, here's what is going on:
>>> import sys
>>> sys.activate_stack_trampoline('perf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: perf trampoline not available
Source: https://github.com/python/cpython/blob/3.12/Python/sysmodule.c#L2166-L2168
I think that I can add a def activate_stack_trampoline(__backend: str) -> NoReturn
for non-linux versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually be okay with keeping the sys.version_info
branch and adding allowlist entries on Windows/Darwin in that case! (We should add comments to the allowlist saying why they're not included, though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that adding it is better, users might do something like:
try:
sys.activate_stack_trampoline('perf')
except ValueError:
some_other_case()
And it is quite easy to do with conditional definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense!
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Source: https://github.com/python/cpython/blob/3.12/Python/sysmodule.c
Docs: https://github.com/python/cpython/blob/3.12/Doc/library/sys.rst