Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions stdlib/sys.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,10 @@ if sys.version_info < (3, 8):
# as part of the response to CVE-2020-10735
def set_int_max_str_digits(maxdigits: int) -> None: ...
def get_int_max_str_digits() -> int: ...

if sys.version_info >= (3, 12):
def getunicodeinternedsize() -> int: ...
if sys.platform == "linux":
def activate_stack_trampoline(__backend: str) -> None: ...
def deactivate_stack_trampoline() -> None: ...
def is_stack_trampoline_active() -> bool: ...
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, makes sense!

4 changes: 0 additions & 4 deletions tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ ssl.OP_LEGACY_SERVER_CONNECT
ssl.Options.OP_LEGACY_SERVER_CONNECT
ssl.RAND_pseudo_bytes
ssl.wrap_socket
sys.activate_stack_trampoline
sys.deactivate_stack_trampoline
sys.getunicodeinternedsize
sys.is_stack_trampoline_active
tarfile.AbsoluteLinkError
tarfile.AbsolutePathError
tarfile.FilterError
Expand Down