@@ -565,54 +565,31 @@ def _netbios_getnode():
565565 return _windll_getnode ()
566566
567567
568-
569- _generate_time_safe = _UuidCreate = None
570- _has_uuid_generate_time_safe = None
571-
572568# Import optional C extension at toplevel, to help disabling it when testing
573569try :
574570 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
575574except ImportError :
576575 _uuid = None
576+ _generate_time_safe = None
577+ _UuidCreate = None
578+ _has_uuid_generate_time_safe = None
577579
578580
579581def _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"""
603583
604584
605585def _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."""
609587 if _generate_time_safe :
610588 uuid_time , _ = _generate_time_safe ()
611589 return UUID (bytes = uuid_time ).node
612590
613591def _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."""
616593 if _UuidCreate :
617594 uuid_bytes = _UuidCreate ()
618595 return UUID (bytes_le = uuid_bytes ).node
@@ -692,7 +669,6 @@ def uuid1(node=None, clock_seq=None):
692669
693670 # When the system provides a version-1 UUID generator, use it (but don't
694671 # use UuidCreate here because its UUIDs don't conform to RFC 4122).
695- _load_system_functions ()
696672 if _generate_time_safe is not None and node is clock_seq is None :
697673 uuid_time , safely_generated = _generate_time_safe ()
698674 try :
0 commit comments