GeezerVison is showing github.com — `uuid` has a bunch of deprecated functions: let's decide what to do with them · Issue #113308 · python/cpython
uuid has a bunch of deprecated functions: let's decide what to do with them #113308
DescriptionFeature or enhancement
uuid.py has several protected deprecated functions which are no longer in use:
|
def _load_system_functions(): |
|
"""[DEPRECATED] Platform-specific functions loaded at import time""" |
|
|
|
|
|
def _ipconfig_getnode(): |
|
"""[DEPRECATED] Get the hardware address on Windows.""" |
|
# bpo-40501: UuidCreateSequential() is now the only supported approach |
|
return _windll_getnode() |
|
|
|
def _netbios_getnode(): |
|
"""[DEPRECATED] Get the hardware address on Windows.""" |
|
# bpo-40501: UuidCreateSequential() is now the only supported approach |
|
return _windll_getnode() |
And one unused module-level var:
|
_has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe |
The problem is that they were not deprecated with a warning. Only with docs.
But, right now they are deprecated since 2020.
This has a big history:
Some projects in the wild use _load_system_functions, despite the fact it is deprecated and was never documented and always was protected.
Examples:
So, what should we do?
- Add a proper warning, schedule it for removal in two versions
- Just remove them
I think that 1. is safer.
I would like to work on it after the decision is made.
Linked PRs
Activitygpshead commented on Dec 20, 2023 I'd go with 1., add the warnings to start the clock. Reacted by Hugo van Kemenade, Terry Jan Reedy, adamsilkey-resideo and Petr Viktorin hugovk commented on Dec 20, 2023 1. sounds good, no rush.
Some projects in the wild use _load_system_functions, despite the fact it is deprecated and was never documented and always was protected.
Examples:
And the second one is an inactive fork of the third, I guess just for a PR.
Searching the top 8k PyPI projects, only freezegun and time-machine use any of these four functions:
❯ python3 ~/github/misc/cpython/search_pypi_top.py -q . "_load_system_functions|_ipconfig_getnode|_netbios_getnode|_has_uuid_generate_time_safe"
./freezegun-1.2.2.tar.gz: freezegun-1.2.2/freezegun/api.py: uuid._load_system_functions()
./time_machine-2.13.0.tar.gz: time_machine-2.13.0/src/time_machine/__init__.py: uuid_idempotent_load_system_functions = (
./time_machine-2.13.0.tar.gz: time_machine-2.13.0/src/time_machine/__init__.py: uuid._load_system_functions # type: ignore[attr-defined]
./time_machine-2.13.0.tar.gz: time_machine-2.13.0/src/time_machine/__init__.py: uuid_idempotent_load_system_functions()
./uuid-1.30.tar.gz: uuid-1.30/uuid.py: def _ipconfig_getnode():
./uuid-1.30.tar.gz: uuid-1.30/uuid.py: def _netbios_getnode():
./uuid-1.30.tar.gz: uuid-1.30/uuid.py: getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode]
./ptvsd-4.3.2.zip: ptvsd-4.3.2/src/ptvsd/_vendored/pydevd/_pydev_imps/_pydev_uuid_old.py: def _ipconfig_getnode():
./ptvsd-4.3.2.zip: ptvsd-4.3.2/src/ptvsd/_vendored/pydevd/_pydev_imps/_pydev_uuid_old.py: def _netbios_getnode():
./ptvsd-4.3.2.zip: ptvsd-4.3.2/src/ptvsd/_vendored/pydevd/_pydev_imps/_pydev_uuid_old.py: getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode]
Ping @spulec and @adamchainz to give a heads-up. vstinner commented on Dec 20, 2023 Reacted by Hugo van Kemenade and Terry Jan Reedy sobolevn commented on Feb 26, 2024 @serhiy-storchaka proposes to just remove these functions. I am fine with both versions, so I would like to get more votes :) serhiy-storchaka commented on Feb 26, 2024 PEP 387 only applies to public APIs. We are free not only remove private functions, but change them in breaking way, for example changing the order of parameters and changing their semantic. Exceptions can be made for old and widely used private APIs, but this is not the case. adamchainz commented on Mar 1, 2024 SponsorContributor More actions I agree, just remove them.
I’ve just made this PR to stop time-machine calling _load_system_functions() on Python 3.9+: adamchainz/time-machine#425 . Thanks for the heads up. Reacted by Hugo van Kemenade Reacted by sobolevn hugovk commented on Mar 1, 2024 Fine by me too.
@terryjreedy @gpshead Any objections to just removing these internal functions? They appear to be very rarely used, now by only one in the top 8k. gpshead commented on Mar 2, 2024 Go for it, they're private. I sent a PR for the freezegun code (spulec/freezegun#534), and the time-machine code is already a conditional call based on Python version.
If we encounter any issues with these during the beta period we can re-add the no-op with an actual DeprecationWarning. Reacted by Hugo van Kemenade, sobolevn and Terry Jan Reedy sobolevn commented on Mar 2, 2024 Changing my PR, thanks everyone :) sobolevn commented on Mar 14, 2024 I merged #115934 🎉
Thanks everyone, I hope that this will be smooth!
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|