@@ -565,54 +565,31 @@ def _netbios_getnode():
565
565
return _windll_getnode ()
566
566
567
567
568
-
569
- _generate_time_safe = _UuidCreate = None
570
- _has_uuid_generate_time_safe = None
571
-
572
568
# Import optional C extension at toplevel, to help disabling it when testing
573
569
try :
574
570
import _uuid
571
+ _generate_time_safe = getattr (_uuid , "generate_time_safe" , None )
572
+ _UuidCreate = getattr (_uuid , "UuidCreate" , None )
573
+ _has_uuid_generate_time_safe = _uuid .has_uuid_generate_time_safe
575
574
except ImportError :
576
575
_uuid = None
576
+ _generate_time_safe = None
577
+ _UuidCreate = None
578
+ _has_uuid_generate_time_safe = None
577
579
578
580
579
581
def _load_system_functions ():
580
- """
581
- Try to load platform-specific functions for generating uuids.
582
- """
583
- global _generate_time_safe , _UuidCreate , _has_uuid_generate_time_safe
584
-
585
- if _has_uuid_generate_time_safe is not None :
586
- return
587
-
588
- _has_uuid_generate_time_safe = False
589
-
590
- if sys .platform == "darwin" and int (os .uname ().release .split ('.' )[0 ]) < 9 :
591
- # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
592
- # in issue #8621 the function generates the same sequence of values
593
- # in the parent process and all children created using fork (unless
594
- # those children use exec as well).
595
- #
596
- # Assume that the uuid_generate functions are broken from 10.5 onward,
597
- # the test can be adjusted when a later version is fixed.
598
- pass
599
- elif _uuid is not None :
600
- _generate_time_safe = getattr (_uuid , "generate_time_safe" , None )
601
- _UuidCreate = getattr (_uuid , "UuidCreate" , None )
602
- _has_uuid_generate_time_safe = _uuid .has_uuid_generate_time_safe
582
+ """[DEPRECATED] Platform-specific functions loaded at import time"""
603
583
604
584
605
585
def _unix_getnode ():
606
- """Get the hardware address on Unix using the _uuid extension module
607
- or ctypes."""
608
- _load_system_functions ()
586
+ """Get the hardware address on Unix using the _uuid extension module."""
609
587
if _generate_time_safe :
610
588
uuid_time , _ = _generate_time_safe ()
611
589
return UUID (bytes = uuid_time ).node
612
590
613
591
def _windll_getnode ():
614
- """Get the hardware address on Windows using UuidCreateSequential."""
615
- _load_system_functions ()
592
+ """Get the hardware address on Windows using the _uuid extension module."""
616
593
if _UuidCreate :
617
594
uuid_bytes = _UuidCreate ()
618
595
return UUID (bytes_le = uuid_bytes ).node
@@ -692,7 +669,6 @@ def uuid1(node=None, clock_seq=None):
692
669
693
670
# When the system provides a version-1 UUID generator, use it (but don't
694
671
# use UuidCreate here because its UUIDs don't conform to RFC 4122).
695
- _load_system_functions ()
696
672
if _generate_time_safe is not None and node is clock_seq is None :
697
673
uuid_time , safely_generated = _generate_time_safe ()
698
674
try :
0 commit comments