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 — platform.node() does not return the latest hostname value · Issue #122525 · python/cpython

platform.node() does not return the latest hostname value #122525

New issue
Copy link
New issue
Copy link
Closed
Closed
platform.node() does not return the latest hostname value#122525
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@kashav
kashav
opened on Jul 31, 2024
Issue body actions

Bug report

Bug description:

I think it's because of how cache is implemented for the uname() helper: https://github.com/python/cpython/blob/5377f55b4e022041b7b57b5489c66c9b3c046c7e/Lib/platform.py#L890-L905.\

Given socket.gethostname() exists as well and respects the latest hostname value, maybe this issue is wontfix. Thought I would file it anyhow.

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Linked PRs

  • gh-122549: Allow to invalidate platform's cached results #122547

Activity

  1. kashav
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 31, 2024
  2. kashav commented on Jul 31, 2024

    @kashav
    kashav
    on Jul 31, 2024
    Author
    More actions

    STR in case they help:

    import platform, socket
    print(platform.node(), socket.gethostname())
    # update the machine's hostname (for macOS it's Settings -> General -> Sharing)
    print(platform.node(), socket.gethostname()) # notice that this is reporting the old value
  3. ZeroIntensity commented on Jul 31, 2024

    @ZeroIntensity
    ZeroIntensity
    on Jul 31, 2024
    Member
    More actions

    I'm guessing this is somewhat intentional. platform.node() is equivalent platform.uname().node, and uname() has a cached result.

  4. kashav commented on Jul 31, 2024

    @kashav
    kashav
    on Jul 31, 2024
    Author
    More actions

    Oh I hadn’t noticed that there’s a platform.uname() method as well. I guess this is somewhat intentional then. It would help to document that uname and its dependents rely on a cached result that might be knowingly stale.

    Reacted by Peter Bierma
  5. picnixz commented on Aug 1, 2024

    @picnixz
    picnixz
    on Aug 1, 2024
    Member
    More actions

    Most of the functions in platform are using cached values. However, I somewhat think that we should have a mean to invalidate this cache. I'll prepare a PR for that.

  6. ZeroIntensity
    closed this as completedon Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — 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.