sys.py 744 B

1234567891011121314151617181920212223242526272829303132333435
  1. """
  2. Python polyfills for sys
  3. """
  4. from __future__ import annotations
  5. import sys
  6. from ..decorators import substitute_in_graph
  7. __all__ = [
  8. "intern",
  9. "getrecursionlimit",
  10. ]
  11. # pyrefly: ignore [bad-argument-type]
  12. @substitute_in_graph(sys.intern, can_constant_fold_through=True)
  13. def intern(string: str, /) -> str:
  14. return string
  15. @substitute_in_graph(sys.getrecursionlimit, can_constant_fold_through=True)
  16. def getrecursionlimit() -> int:
  17. return sys.getrecursionlimit()
  18. if hasattr(sys, "get_int_max_str_digits"):
  19. @substitute_in_graph(sys.get_int_max_str_digits, can_constant_fold_through=True)
  20. def get_int_max_str_digits() -> int:
  21. return sys.get_int_max_str_digits()
  22. __all__ += ["get_int_max_str_digits"]