Options: set old options api before the world is created (#2378)

This commit is contained in:
Aaron Wagener
2023-12-16 15:21:05 -06:00
committed by GitHub
parent c56cbd0474
commit 7dff09dc1a
3 changed files with 33 additions and 5 deletions

View File

@@ -779,6 +779,25 @@ def deprecate(message: str):
import warnings
warnings.warn(message)
class DeprecateDict(dict):
log_message: str
should_error: bool
def __init__(self, message, error: bool = False) -> None:
self.log_message = message
self.should_error = error
super().__init__()
def __getitem__(self, item: Any) -> Any:
if self.should_error:
deprecate(self.log_message)
elif __debug__:
import warnings
warnings.warn(self.log_message)
return super().__getitem__(item)
def _extend_freeze_support() -> None:
"""Extend multiprocessing.freeze_support() to also work on Non-Windows for spawn."""
# upstream issue: https://github.com/python/cpython/issues/76327