GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

New issue
Copy link
New issue
Copy link
Closed
Closed
uuid has a bunch of deprecated functions: let's decide what to do with them#113308
Copy link
Assignees
sobolevn
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@sobolevn
sobolevn
opened on Dec 20, 2023
Issue body actions

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:

cpython/Lib/uuid.py

Line 583 in 4afa7be

_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:

  • Fix uuid.uuid1() core logic of uuid.getnode() needs refresh #72196
  • Deprecate and remove ctypes usage in uuid #84681 and bpo-40501: Replace ctypes code in uuid with native module #19948
  • bpo-11063, bpo-20519: avoid ctypes and improve import time for uuid #3796

Some projects in the wild use _load_system_functions, despite the fact it is deprecated and was never documented and always was protected.

Examples:

  • https://github.com/spulec/freezegun/blob/5e06dff53244992204706adf6907e7138ac96d39/freezegun/api.py#L71
  • https://github.com/pganssle/time-machine/blob/ccc59927b4c51e35895c34578cba7aca69f28055/src/time_machine/__init__.py#L211
  • https://github.com/adamchainz/time-machine/blob/39e327e18d52ebc76d3973b465ff42e139fd651d/src/time_machine/__init__.py#L223

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.

Linked PRs

  • gh-113308: Remove some internal parts of uuid module #115934
  • gh-113308: Restore uuid._load_system_functions for 3.13 #117832

Activity

  1. sobolevn
    added
    type-featureA feature request or enhancementA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Dec 20, 2023
  2. sobolevn
    self-assigned this
    on Dec 20, 2023
  3. gpshead commented on Dec 20, 2023

    @gpshead
    gpshead
    on Dec 20, 2023
    Member
    More actions

    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
  4. hugovk commented on Dec 20, 2023

    @hugovk
    hugovk
    on Dec 20, 2023
    Member
    More actions

    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:

    • spulec/freezegun@5e06dff/freezegun/api.py#L71
    • pganssle/time-machine@ccc5992/src/time_machine/init.py#L211
    • adamchainz/time-machine@39e327e/src/time_machine/init.py#L223

    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.

  5. vstinner commented on Dec 20, 2023

    @vstinner
    vstinner
    on Dec 20, 2023
    Member
    More actions

    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

    Reacted by Hugo van Kemenade and Terry Jan Reedy
  6. sobolevn
    added 3 commits that reference this issue on Feb 26, 2024

    pythongh-113308: Deprecate some internal parts of `uuid` module

    96ead70

    pythongh-113308: Deprecate some internal parts of `uuid` module

    7cc1d76

    pythongh-113308: Deprecate some internal parts of `uuid` module

    1b8a3ad
  7. sobolevn commented on Feb 26, 2024

    @sobolevn
    sobolevn
    on Feb 26, 2024
    MemberAuthor
    More actions

    @serhiy-storchaka proposes to just remove these functions. I am fine with both versions, so I would like to get more votes :)

  8. serhiy-storchaka commented on Feb 26, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Feb 26, 2024
    Member
    More actions

    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.

  9. adamchainz commented on Mar 1, 2024

    @adamchainz
    adamchainz
    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
  10. hugovk commented on Mar 1, 2024

    @hugovk
    hugovk
    on Mar 1, 2024
    Member
    More actions

    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.

  11. gpshead commented on Mar 2, 2024

    @gpshead
    gpshead
    on Mar 2, 2024
    Member
    More actions

    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
  12. sobolevn commented on Mar 2, 2024

    @sobolevn
    sobolevn
    on Mar 2, 2024
    MemberAuthor
    More actions

    Changing my PR, thanks everyone :)

  13. inmantaci
    added 2 commits that reference this issue on Mar 4, 2024

    Bump time-machine from 2.13.0 to 2.14.0 (PR #7305)

    384df2d

    Bump time-machine from 2.13.0 to 2.14.0 (PR #7303)

    b0287e5
  14. sobolevn
    added a commit that references this issue on Mar 14, 2024

    gh-113308: Remove some internal parts of `uuid` module (#115934)

    61f576a
  15. sobolevn commented on Mar 14, 2024

    @sobolevn
    sobolevn
    on Mar 14, 2024
    MemberAuthor
    More actions

    I merged #115934 🎉
    Thanks everyone, I hope that this will be smooth!

  16. sobolevn
    closed this as completedon Mar 14, 2024
  17. vstinner
    added a commit that references this issue on Mar 20, 2024

    pythongh-113308: Remove some internal parts of `uuid` module (python#…

    c742f43
  18. adorilson
    added a commit that references this issue on Mar 25, 2024

    pythongh-113308: Remove some internal parts of `uuid` module (python#…

    705e327
  19. gpshead
    added a commit that references this issue on Apr 13, 2024

    pythongh-113308: Restore `uuid._load_system_functions` for 3.13

    1925d53
  20. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythongh-113308: Remove some internal parts of `uuid` module (python#…

    e5561b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.