Skip to content

Commit 2eda5ad

Browse files
authored
Avoid calling uuid._load_system_functions() on Python 3.9+. (#425)
1 parent 4bd96a2 commit 2eda5ad

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Changelog
33
=========
44

5+
* Avoid calling deprecated ``uuid._load_system_functions()`` on Python 3.9+.
6+
7+
Thanks to Nikita Sobolev for the ping in `CPython Issue #113308 <https://github.com/python/cpython/issues/113308>`__.
8+
59
2.13.0 (2023-09-19)
610
-------------------
711

src/time_machine/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ def _stop(self) -> None:
217217
uuid_generate_time_attr = "_generate_time_safe"
218218
uuid_generate_time_patcher = mock.patch.object(uuid, uuid_generate_time_attr, new=None)
219219
uuid_uuid_create_patcher = mock.patch.object(uuid, "_UuidCreate", new=None)
220-
# We need to cause the functions to be loaded before we try patch them out,
221-
# which is done by this internal function
222-
uuid_idempotent_load_system_functions = (
223-
uuid._load_system_functions # type: ignore[attr-defined]
224-
)
225220

226221

227222
class travel:
@@ -237,7 +232,11 @@ def start(self) -> Coordinates:
237232
_time_machine.patch_if_needed()
238233

239234
if not coordinates_stack:
240-
uuid_idempotent_load_system_functions()
235+
if sys.version_info < (3, 9):
236+
# We need to cause the functions to be loaded before we patch
237+
# them out, which is done by this internal function before:
238+
# https://github.com/python/cpython/pull/19948
239+
uuid._load_system_functions()
241240
uuid_generate_time_patcher.start()
242241
uuid_uuid_create_patcher.start()
243242

0 commit comments

Comments
 (0)