Skip to content

Commit

Permalink
Change the PR to remove these internal parts instead
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Mar 3, 2024
1 parent 48ed729 commit ee231d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 58 deletions.
5 changes: 0 additions & 5 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,6 @@ Pending Removal in Python 3.15
in Python 3.15. To create a TypedDict class with 0 fields, use ``class
TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.

* :mod:`uuid`: Deprecate some internal protected parts:
``_has_uuid_generate_time_safe``, ``_netbios_getnode``, ``_ipconfig_getnode``,
and ``_load_system_functions``. They will be removed in Python 3.15.
(Contributed by Nikita Sobolev in :gh:`113308`.)

* :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()``
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
They will be removed in Python 3.15.
Expand Down
32 changes: 10 additions & 22 deletions Lib/test/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,14 @@ def test_uuid1(self):
@support.requires_mac_ver(10, 5)
@unittest.skipUnless(os.name == 'posix', 'POSIX-only test')
def test_uuid1_safe(self):
msg = re.escape("'_has_uuid_generate_time_safe' is deprecated and "
"slated for removal in Python 3.15")
with self.assertWarnsRegex(DeprecationWarning, msg):
has_uuid_generate_time_safe = self.uuid._has_uuid_generate_time_safe
try:
import _uuid
except ImportError:
has_uuid_generate_time_safe = False
else:
has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe
import_helper.unload('_uuid')

if not has_uuid_generate_time_safe:
self.skipTest('requires uuid_generate_time_safe(3)')

Expand All @@ -551,10 +555,6 @@ def mock_generate_time_safe(self, safe_value):
"""
if os.name != 'posix':
self.skipTest('POSIX-only test')
msg = re.escape("'_load_system_functions' is deprecated and "
"slated for removal in Python 3.15")
with self.assertWarnsRegex(DeprecationWarning, msg):
self.uuid._load_system_functions()
f = self.uuid._generate_time_safe
if f is None:
self.skipTest('need uuid._generate_time_safe')
Expand Down Expand Up @@ -589,27 +589,15 @@ def test_uuid1_bogus_return_value(self):
self.assertEqual(u.is_safe, self.uuid.SafeUUID.unknown)

def test_uuid1_time(self):
@contextlib.contextmanager
def patch_has_uuid_generate_time_safe(value):
msg = re.escape("'_has_uuid_generate_time_safe' is deprecated and "
"slated for removal in Python 3.15")
with self.assertWarnsRegex(DeprecationWarning, msg):
with mock.patch.object(
self.uuid, '_has_uuid_generate_time_safe', value,
) as patched:
yield patched

with patch_has_uuid_generate_time_safe(False), \
mock.patch.object(self.uuid, '_generate_time_safe', None), \
with mock.patch.object(self.uuid, '_generate_time_safe', None), \
mock.patch.object(self.uuid, '_last_timestamp', None), \
mock.patch.object(self.uuid, 'getnode', return_value=93328246233727), \
mock.patch('time.time_ns', return_value=1545052026752910643), \
mock.patch('random.getrandbits', return_value=5317): # guaranteed to be random
u = self.uuid.uuid1()
self.assertEqual(u, self.uuid.UUID('a7a55b92-01fc-11e9-94c5-54e1acf6da7f'))

with patch_has_uuid_generate_time_safe(False), \
mock.patch.object(self.uuid, '_generate_time_safe', None), \
with mock.patch.object(self.uuid, '_generate_time_safe', None), \
mock.patch.object(self.uuid, '_last_timestamp', None), \
mock.patch('time.time_ns', return_value=1545052026752910643):
u = self.uuid.uuid1(node=93328246233727, clock_seq=5317)
Expand Down
28 changes: 0 additions & 28 deletions Lib/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

import os
import sys
import warnings

from enum import Enum, _simple_enum

Expand Down Expand Up @@ -565,18 +564,6 @@ def _netstat_getnode():
# This works on AIX and might work on Tru64 UNIX.
return _find_mac_under_heading('netstat', '-ian', b'Address')

def _ipconfig_getnode():
"""[DEPRECATED] Get the hardware address on Windows."""
warnings._deprecated("_ipconfig_getnode", remove=(3, 15))
# bpo-40501: UuidCreateSequential() is now the only supported approach
return _windll_getnode()

def _netbios_getnode():
"""[DEPRECATED] Get the hardware address on Windows."""
warnings._deprecated("_netbios_getnode", remove=(3, 15))
# bpo-40501: UuidCreateSequential() is now the only supported approach
return _windll_getnode()


# Import optional C extension at toplevel, to help disabling it when testing
try:
Expand All @@ -589,21 +576,6 @@ def _netbios_getnode():
_UuidCreate = None


def __getattr__(attr):
if attr == "_has_uuid_generate_time_safe":
warnings._deprecated("_has_uuid_generate_time_safe", remove=(3, 15))
if _uuid is None:
return None
else:
return _uuid.has_uuid_generate_time_safe
raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")


def _load_system_functions():
"""[DEPRECATED] Platform-specific functions loaded at import time"""
warnings._deprecated("_load_system_functions", remove=(3, 15))


def _unix_getnode():
"""Get the hardware address on Unix using the _uuid extension module."""
if _generate_time_safe:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:mod:`uuid`: Deprecate some internal protected parts:
Remove some internal protected parts from :mod:`uuid`:
``_has_uuid_generate_time_safe``, ``_netbios_getnode``,
``_ipconfig_getnode``, and ``_load_system_functions``. They will be removed
in Python 3.15.
``_ipconfig_getnode``, and ``_load_system_functions``.
They were unused.

0 comments on commit ee231d3

Please sign in to comment.