diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 17f3d51..1363a40 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,10 @@ Changelog ========= +* Avoid calling deprecated ``uuid._load_system_functions()`` on Python 3.9+. + + Thanks to Nikita Sobolev for the ping in `CPython Issue #113308 `__. + 2.13.0 (2023-09-19) ------------------- diff --git a/src/time_machine/__init__.py b/src/time_machine/__init__.py index b39427d..4a6acd8 100644 --- a/src/time_machine/__init__.py +++ b/src/time_machine/__init__.py @@ -217,11 +217,6 @@ def _stop(self) -> None: uuid_generate_time_attr = "_generate_time_safe" uuid_generate_time_patcher = mock.patch.object(uuid, uuid_generate_time_attr, new=None) uuid_uuid_create_patcher = mock.patch.object(uuid, "_UuidCreate", new=None) -# We need to cause the functions to be loaded before we try patch them out, -# which is done by this internal function -uuid_idempotent_load_system_functions = ( - uuid._load_system_functions # type: ignore[attr-defined] -) class travel: @@ -237,7 +232,11 @@ def start(self) -> Coordinates: _time_machine.patch_if_needed() if not coordinates_stack: - uuid_idempotent_load_system_functions() + if sys.version_info < (3, 9): + # We need to cause the functions to be loaded before we patch + # them out, which is done by this internal function before: + # https://github.com/python/cpython/pull/19948 + uuid._load_system_functions() uuid_generate_time_patcher.start() uuid_uuid_create_patcher.start()