Skip to content

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

Merged
merged 5 commits into from
Jun 5, 2023
Merged

Update sys.pyi for Python3.12 #10245

merged 5 commits into from
Jun 5, 2023

Conversation

@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator

(Let's merge in #10253 first)

@github-actions

This comment has been minimized.

@JelleZijlstra
Copy link
Member

Looks like you get to remove some allowlist entries :)

stdlib/sys.pyi Outdated
Comment on lines 365 to 368
if sys.platform == "linux":
def activate_stack_trampoline(__backend: str) -> None: ...
def deactivate_stack_trampoline() -> None: ...
def is_stack_trampoline_active() -> bool: ...
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

@AlexWaygood AlexWaygood Jun 5, 2023

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).

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense!

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2023

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit 59d08c0 into main Jun 5, 2023
@AlexWaygood AlexWaygood deleted the sobolevn-patch-2 branch June 5, 2023 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants