You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importplatform, socketprint(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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
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
The text was updated successfully, but these errors were encountered: