The Wayback Machine - https://web.archive.org/web/20240106171009/https://github.com/python/cpython/issues/113308
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uuid has a bunch of deprecated functions: let's decide what to do with them #113308

Open
sobolevn opened this issue Dec 20, 2023 · 3 comments
Open
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@sobolevn
Copy link
Member

sobolevn commented Dec 20, 2023

Feature or enhancement

uuid.py has several protected deprecated functions which are no longer in use:

cpython/Lib/uuid.py

Lines 591 to 594 in 4afa7be

def _load_system_functions():
"""[DEPRECATED] Platform-specific functions loaded at import time"""

cpython/Lib/uuid.py

Lines 567 to 575 in 4afa7be

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?

  1. Add a proper warning, schedule it for removal in two versions
  2. Just remove them

I think that 1. is safer.
I would like to work on it after the decision is made.

@sobolevn sobolevn added type-feature A feature request or enhancement stdlib Python modules in the Lib dir labels Dec 20, 2023
@sobolevn sobolevn self-assigned this Dec 20, 2023
@gpshead
Copy link
Member

gpshead commented Dec 20, 2023

I'd go with 1., add the warnings to start the clock.

@hugovk
Copy link
Member

hugovk commented 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
Copy link
Member

If you start to emit a DeprecationWarning right now, you respect PEP 387, and so you will be able to remove the code in 2 releases (Python 3.15) in a safe way. You can also announce the removal at: https://docs.python.org/dev/whatsnew/3.13.html#pending-removal-in-python-3-15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants