Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 61f576a

Browse filesBrowse files
sobolevnhugovk
andauthored
gh-113308: Remove some internal parts of uuid module (#115934)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 66fb613 commit 61f576a
Copy full SHA for 61f576a

File tree

Expand file treeCollapse file tree

3 files changed

+14
-22
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-22
lines changed

‎Lib/test/test_uuid.py

Copy file name to clipboardExpand all lines: Lib/test/test_uuid.py
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,14 @@ def test_uuid1(self):
530530
@support.requires_mac_ver(10, 5)
531531
@unittest.skipUnless(os.name == 'posix', 'POSIX-only test')
532532
def test_uuid1_safe(self):
533-
if not self.uuid._has_uuid_generate_time_safe:
533+
try:
534+
import _uuid
535+
except ImportError:
536+
has_uuid_generate_time_safe = False
537+
else:
538+
has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe
539+
540+
if not has_uuid_generate_time_safe or not self.uuid._generate_time_safe:
534541
self.skipTest('requires uuid_generate_time_safe(3)')
535542

536543
u = self.uuid.uuid1()
@@ -546,7 +553,6 @@ def mock_generate_time_safe(self, safe_value):
546553
"""
547554
if os.name != 'posix':
548555
self.skipTest('POSIX-only test')
549-
self.uuid._load_system_functions()
550556
f = self.uuid._generate_time_safe
551557
if f is None:
552558
self.skipTest('need uuid._generate_time_safe')
@@ -581,17 +587,15 @@ def test_uuid1_bogus_return_value(self):
581587
self.assertEqual(u.is_safe, self.uuid.SafeUUID.unknown)
582588

583589
def test_uuid1_time(self):
584-
with mock.patch.object(self.uuid, '_has_uuid_generate_time_safe', False), \
585-
mock.patch.object(self.uuid, '_generate_time_safe', None), \
590+
with mock.patch.object(self.uuid, '_generate_time_safe', None), \
586591
mock.patch.object(self.uuid, '_last_timestamp', None), \
587592
mock.patch.object(self.uuid, 'getnode', return_value=93328246233727), \
588593
mock.patch('time.time_ns', return_value=1545052026752910643), \
589594
mock.patch('random.getrandbits', return_value=5317): # guaranteed to be random
590595
u = self.uuid.uuid1()
591596
self.assertEqual(u, self.uuid.UUID('a7a55b92-01fc-11e9-94c5-54e1acf6da7f'))
592597

593-
with mock.patch.object(self.uuid, '_has_uuid_generate_time_safe', False), \
594-
mock.patch.object(self.uuid, '_generate_time_safe', None), \
598+
with mock.patch.object(self.uuid, '_generate_time_safe', None), \
595599
mock.patch.object(self.uuid, '_last_timestamp', None), \
596600
mock.patch('time.time_ns', return_value=1545052026752910643):
597601
u = self.uuid.uuid1(node=93328246233727, clock_seq=5317)

‎Lib/uuid.py

Copy file name to clipboardExpand all lines: Lib/uuid.py
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -567,32 +567,16 @@ def _netstat_getnode():
567567
# This works on AIX and might work on Tru64 UNIX.
568568
return _find_mac_under_heading('netstat', '-ian', b'Address')
569569

570-
def _ipconfig_getnode():
571-
"""[DEPRECATED] Get the hardware address on Windows."""
572-
# bpo-40501: UuidCreateSequential() is now the only supported approach
573-
return _windll_getnode()
574-
575-
def _netbios_getnode():
576-
"""[DEPRECATED] Get the hardware address on Windows."""
577-
# bpo-40501: UuidCreateSequential() is now the only supported approach
578-
return _windll_getnode()
579-
580570

581571
# Import optional C extension at toplevel, to help disabling it when testing
582572
try:
583573
import _uuid
584574
_generate_time_safe = getattr(_uuid, "generate_time_safe", None)
585575
_UuidCreate = getattr(_uuid, "UuidCreate", None)
586-
_has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe
587576
except ImportError:
588577
_uuid = None
589578
_generate_time_safe = None
590579
_UuidCreate = None
591-
_has_uuid_generate_time_safe = None
592-
593-
594-
def _load_system_functions():
595-
"""[DEPRECATED] Platform-specific functions loaded at import time"""
596580

597581

598582
def _unix_getnode():
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Remove some internal protected parts from :mod:`uuid`:
2+
``_has_uuid_generate_time_safe``, ``_netbios_getnode``,
3+
``_ipconfig_getnode``, and ``_load_system_functions``.
4+
They were unused.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.