homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python 2.7 platform.system reports wrong on Mac OS X El Capitan
Type: Stage:
Components: macOS Versions: Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: Audric D'Hoest (Dr. Pariolo), lemburg, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2016年06月16日 18:47 by Audric D'Hoest (Dr. Pariolo), last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pybug.png Audric D'Hoest (Dr. Pariolo), 2016年06月16日 18:47
Messages (3)
msg268687 - (view) Author: Audric D'Hoest (Dr. Pariolo) (Audric D'Hoest (Dr. Pariolo)) Date: 2016年06月16日 18:47
Mac mini late 2014, upgraded to El capitan.
Out of the box python 2.7 reports the wrong system info.
platform.system() should report El Capitan
platform.release() should report 10.11.5
msg268689 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016年06月16日 19:12
Python's platform module has both platform-independent and platform-dependent functions as noted in its documentation. While it isn't as clearly documented as perhaps it should be, on most "Unix-y" platforms, like OS X, much of the platform-independent system information comes from the same source as the platform's "uname" command. You can see that, if you use platform.uname(), it matches the output of OS X's uname(1) command:
>>> platform.uname()
('Darwin', 'kitt.local', '15.5.0', 'Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-32485021~8/RELEASE_X86_64', 'x86_64', 'i386')
>>> platform.system()
'Darwin'
>>> platform.release()
'15.5.0'
$ uname -a
Darwin kitt.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-32485021~8/RELEASE_X86_64 x86_64
Somewhat confusingly, "Darwin" is how the OS X kernel identifies itself and "15.5.0" is the Darwin version number that corresponds to OS X 10.11.5. And the uname output is what the platform module uses.
For OS X, the platform module does provide a Mac-specific function, platform.mac_ver. From it, you can get the OS X version information, rather than the Darwin kernel information.
>>> platform.mac_ver()
('10.11.5', ('', '', ''), 'x86_64')
Suggestions on how to improve the documentation are welcome! But changing the results from the platform-independent functions after all these years is not likely to happen.
https://docs.python.org/2.7/library/platform.html#cross-platform
https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history 
msg268691 - (view) Author: Audric D'Hoest (Dr. Pariolo) (Audric D'Hoest (Dr. Pariolo)) Date: 2016年06月16日 19:29
Hello Ned,
That is a brilliant answer!
After reporting this initially, I tried with 3.5.1, and uname... Convinced it was a 2.7.1, I could not be more wrong! What a stupid and confusing output does the OS report.
platform.mac_ver() does the trick!
thank you!
History
Date User Action Args
2022年04月11日 14:58:32adminsetgithub: 71525
2016年06月16日 19:30:18Audric D'Hoest (Dr. Pariolo)setstatus: open -> closed
resolution: works for me
2016年06月16日 19:29:31Audric D'Hoest (Dr. Pariolo)setmessages: + msg268691
2016年06月16日 19:12:58ned.deilysetnosy: + lemburg
messages: + msg268689
2016年06月16日 18:55:36Audric D'Hoest (Dr. Pariolo)settitle: python 2.7 platform.system reports wrong -> python 2.7 platform.system reports wrong on Mac OS X El Capitan
2016年06月16日 18:47:37Audric D'Hoest (Dr. Pariolo)create

AltStyle によって変換されたページ (->オリジナル) /