From 1b8a3ad2ce8ccaeb9c1badbbcdeb5ab964039cb5 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 26 Feb 2024 10:07:30 +0300 Subject: [PATCH 1/8] gh-113308: Deprecate some internal parts of `uuid` module --- Doc/whatsnew/3.13.rst | 5 +++++ Lib/test/test_uuid.py | 22 +++++++++++++++---- Lib/uuid.py | 19 ++++++++++++++-- ...-02-26-10-06-50.gh-issue-113308.MbvOFt.rst | 4 ++++ 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index ca5a0e7515994f..ed77527d6e3831 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -924,6 +924,11 @@ Pending Removal in Python 3.15 They will be removed in Python 3.15. (Contributed by Victor Stinner in :gh:`105096`.) +* :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`.) + Pending Removal in Python 3.16 ------------------------------ diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 9cec1e87fd3c2d..0f134f441fa417 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -8,6 +8,7 @@ import io import os import pickle +import re import sys import weakref from unittest import mock @@ -530,7 +531,11 @@ def test_uuid1(self): @support.requires_mac_ver(10, 5) @unittest.skipUnless(os.name == 'posix', 'POSIX-only test') def test_uuid1_safe(self): - if not self.uuid._has_uuid_generate_time_safe: + 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 + if not has_uuid_generate_time_safe: self.skipTest('requires uuid_generate_time_safe(3)') u = self.uuid.uuid1() @@ -546,7 +551,6 @@ def mock_generate_time_safe(self, safe_value): """ if os.name != 'posix': self.skipTest('POSIX-only test') - self.uuid._load_system_functions() f = self.uuid._generate_time_safe if f is None: self.skipTest('need uuid._generate_time_safe') @@ -581,7 +585,17 @@ def test_uuid1_bogus_return_value(self): self.assertEqual(u.is_safe, self.uuid.SafeUUID.unknown) def test_uuid1_time(self): - with mock.patch.object(self.uuid, '_has_uuid_generate_time_safe', False), \ + @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), \ mock.patch.object(self.uuid, '_last_timestamp', None), \ mock.patch.object(self.uuid, 'getnode', return_value=93328246233727), \ @@ -590,7 +604,7 @@ def test_uuid1_time(self): u = self.uuid.uuid1() self.assertEqual(u, self.uuid.UUID('a7a55b92-01fc-11e9-94c5-54e1acf6da7f')) - with mock.patch.object(self.uuid, '_has_uuid_generate_time_safe', False), \ + with patch_has_uuid_generate_time_safe(False), \ 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): diff --git a/Lib/uuid.py b/Lib/uuid.py index 470bc0d68597ab..61db8b25756adc 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -46,6 +46,7 @@ import os import sys +import warnings from enum import Enum, _simple_enum @@ -566,11 +567,13 @@ def _netstat_getnode(): 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() @@ -580,16 +583,28 @@ def _netbios_getnode(): import _uuid _generate_time_safe = getattr(_uuid, "generate_time_safe", None) _UuidCreate = getattr(_uuid, "UuidCreate", None) - _has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe except ImportError: _uuid = None _generate_time_safe = None _UuidCreate = None - _has_uuid_generate_time_safe = None + + +def __getattr__(attr): + if attr == "_has_uuid_generate_time_safe": + try: + import _uuid + except ImportError: + _has_uuid_generate_time_safe = None + else: + _has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe + warnings._deprecated("_has_uuid_generate_time_safe", remove=(3, 15)) + return _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(): diff --git a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst new file mode 100644 index 00000000000000..ad5e022b314c90 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst @@ -0,0 +1,4 @@ +: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. From c198931d9ed2959fd0fa0c428f27ec0718d8c17f Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 26 Feb 2024 11:41:11 +0300 Subject: [PATCH 2/8] Address review --- Doc/whatsnew/3.13.rst | 10 +++++----- Lib/test/test_uuid.py | 4 ++++ Lib/uuid.py | 7 +++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index ed77527d6e3831..48628bab9d39ac 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -919,16 +919,16 @@ 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:`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. - (Contributed by Victor Stinner in :gh:`105096`.) - * :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. + (Contributed by Victor Stinner in :gh:`105096`.) + Pending Removal in Python 3.16 ------------------------------ diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 0f134f441fa417..4ee69bf3902910 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -551,6 +551,10 @@ 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') diff --git a/Lib/uuid.py b/Lib/uuid.py index 61db8b25756adc..7d6a17384432d1 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -591,14 +591,13 @@ def _netbios_getnode(): def __getattr__(attr): if attr == "_has_uuid_generate_time_safe": + warnings._deprecated("_has_uuid_generate_time_safe", remove=(3, 15)) try: import _uuid except ImportError: - _has_uuid_generate_time_safe = None + return None else: - _has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe - warnings._deprecated("_has_uuid_generate_time_safe", remove=(3, 15)) - return _has_uuid_generate_time_safe + return _uuid.has_uuid_generate_time_safe raise AttributeError(f"module {__name__!r} has no attribute {attr!r}") From 6bea9fc3e127cd1656d505e1598b0204feaf4c62 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 26 Feb 2024 12:00:27 +0300 Subject: [PATCH 3/8] Do not import `_uuid` twice --- Lib/uuid.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index 7d6a17384432d1..2ab5a2548d1872 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -592,9 +592,7 @@ def _netbios_getnode(): def __getattr__(attr): if attr == "_has_uuid_generate_time_safe": warnings._deprecated("_has_uuid_generate_time_safe", remove=(3, 15)) - try: - import _uuid - except ImportError: + if _uuid is None: return None else: return _uuid.has_uuid_generate_time_safe From ee231d3f5a0295cb034902f154536ab539e3cfaa Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 3 Mar 2024 10:46:51 +0300 Subject: [PATCH 4/8] Change the PR to remove these internal parts instead --- Doc/whatsnew/3.13.rst | 5 --- Lib/test/test_uuid.py | 32 ++++++------------- Lib/uuid.py | 28 ---------------- ...-02-26-10-06-50.gh-issue-113308.MbvOFt.rst | 6 ++-- 4 files changed, 13 insertions(+), 58 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 77d8ee06bef6ce..d08c63e7b2c2c5 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -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. diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 4ee69bf3902910..5c74723a14dcc3 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -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)') @@ -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') @@ -589,18 +589,7 @@ 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), \ @@ -608,8 +597,7 @@ def patch_has_uuid_generate_time_safe(value): 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) diff --git a/Lib/uuid.py b/Lib/uuid.py index 2ab5a2548d1872..f54e8b0237c3e7 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -46,7 +46,6 @@ import os import sys -import warnings from enum import Enum, _simple_enum @@ -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: @@ -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: diff --git a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst index ad5e022b314c90..c4c242fe3d578f 100644 --- a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst +++ b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst @@ -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. From 967c59b9c2aa8cc76174ab1d182d6421126b15d4 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 3 Mar 2024 11:47:09 +0300 Subject: [PATCH 5/8] Fix CI --- Lib/test/test_uuid.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 5c74723a14dcc3..c3231af20cf7f1 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -537,9 +537,8 @@ def test_uuid1_safe(self): 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: + if not has_uuid_generate_time_safe or not self.uuid._generate_time_safe: self.skipTest('requires uuid_generate_time_safe(3)') u = self.uuid.uuid1() From 10dc8c2857e4752fc805d9c2d61fb29b184d759c Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 3 Mar 2024 14:24:43 +0300 Subject: [PATCH 6/8] Also remove `has_uuid_generate_time_safe` from `_uuid` module --- Lib/test/test_uuid.py | 9 +-------- .../2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst | 1 + Modules/_uuidmodule.c | 11 ----------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index c3231af20cf7f1..9ee31c30909427 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -531,14 +531,7 @@ def test_uuid1(self): @support.requires_mac_ver(10, 5) @unittest.skipUnless(os.name == 'posix', 'POSIX-only test') def test_uuid1_safe(self): - try: - import _uuid - except ImportError: - has_uuid_generate_time_safe = False - else: - has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe - - if not has_uuid_generate_time_safe or not self.uuid._generate_time_safe: + if not self.uuid._generate_time_safe: self.skipTest('requires uuid_generate_time_safe(3)') u = self.uuid.uuid1() diff --git a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst index c4c242fe3d578f..983c865c402f8a 100644 --- a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst +++ b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst @@ -1,4 +1,5 @@ Remove some internal protected parts from :mod:`uuid`: ``_has_uuid_generate_time_safe``, ``_netbios_getnode``, ``_ipconfig_getnode``, and ``_load_system_functions``. +Also remove ``has_uuid_generate_time_safe`` from ``_uuid`` module. They were unused. diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c index 4b6852c0d0ec73..8c5b1de6dcf9c4 100644 --- a/Modules/_uuidmodule.c +++ b/Modules/_uuidmodule.c @@ -85,17 +85,6 @@ py_UuidCreate(PyObject *Py_UNUSED(context), static int uuid_exec(PyObject *module) { assert(sizeof(uuid_t) == 16); -#if defined(MS_WINDOWS) - int has_uuid_generate_time_safe = 0; -#elif defined(HAVE_UUID_GENERATE_TIME_SAFE) - int has_uuid_generate_time_safe = 1; -#else - int has_uuid_generate_time_safe = 0; -#endif - if (PyModule_AddIntConstant(module, "has_uuid_generate_time_safe", - has_uuid_generate_time_safe) < 0) { - return -1; - } return 0; } From df762ec57a43fcbc1427445a81eada1bb491a9ea Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 3 Mar 2024 15:50:56 +0300 Subject: [PATCH 7/8] Revert "Also remove `has_uuid_generate_time_safe` from `_uuid` module" This reverts commit 10dc8c2857e4752fc805d9c2d61fb29b184d759c. --- Lib/test/test_uuid.py | 9 ++++++++- .../2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst | 1 - Modules/_uuidmodule.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 9ee31c30909427..c3231af20cf7f1 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -531,7 +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): - if not self.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 + + if not has_uuid_generate_time_safe or not self.uuid._generate_time_safe: self.skipTest('requires uuid_generate_time_safe(3)') u = self.uuid.uuid1() diff --git a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst index 983c865c402f8a..c4c242fe3d578f 100644 --- a/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst +++ b/Misc/NEWS.d/next/Library/2024-02-26-10-06-50.gh-issue-113308.MbvOFt.rst @@ -1,5 +1,4 @@ Remove some internal protected parts from :mod:`uuid`: ``_has_uuid_generate_time_safe``, ``_netbios_getnode``, ``_ipconfig_getnode``, and ``_load_system_functions``. -Also remove ``has_uuid_generate_time_safe`` from ``_uuid`` module. They were unused. diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c index 8c5b1de6dcf9c4..4b6852c0d0ec73 100644 --- a/Modules/_uuidmodule.c +++ b/Modules/_uuidmodule.c @@ -85,6 +85,17 @@ py_UuidCreate(PyObject *Py_UNUSED(context), static int uuid_exec(PyObject *module) { assert(sizeof(uuid_t) == 16); +#if defined(MS_WINDOWS) + int has_uuid_generate_time_safe = 0; +#elif defined(HAVE_UUID_GENERATE_TIME_SAFE) + int has_uuid_generate_time_safe = 1; +#else + int has_uuid_generate_time_safe = 0; +#endif + if (PyModule_AddIntConstant(module, "has_uuid_generate_time_safe", + has_uuid_generate_time_safe) < 0) { + return -1; + } return 0; } From 0eec764528fa6bd3f0e7ede6a4914e87f5bf8d28 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 3 Mar 2024 19:06:48 +0300 Subject: [PATCH 8/8] Update Lib/test/test_uuid.py Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Lib/test/test_uuid.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index c3231af20cf7f1..e177464c00f7a6 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -8,7 +8,6 @@ import io import os import pickle -import re import sys import weakref from unittest import mock