I'm using Python platform module to identify the MacOS version like this:
import platform
print(platform.mac_ver())
Output:
In [1]: import platform
In [2]: platform.mac_ver()
Out[2]: ('10.16', ('', '', ''), 'x86_64')
I have updated to BigSur and the version is incorrect, it should be 11.0.1
I looked at the source code of platform and it seems to parse a this file /System/Library/CoreServices/SystemVersion.plist to get the information. When reading this file from Python I get an incorrect version but from bash it is the correct one
Bash:
Amirs-MacBook-Pro:~ arossert$ cat /System/Library/CoreServices/SystemVersion.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string>20B50</string>
<key>ProductCopyright</key>
<string>1983-2020 Apple Inc.</string>
<key>ProductName</key>
<string>macOS</string>
<key>ProductUserVisibleVersion</key>
<string>11.0.1</string>
<key>ProductVersion</key>
<string>11.0.1</string>
<key>iOSSupportVersion</key>
<string>14.2</string>
</dict>
</plist>
Python:
In [4]: print(open("/System/Library/CoreServices/SystemVersion.plist").read())
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string>20B50</string>
<key>ProductCopyright</key>
<string>1983-2020 Apple Inc.</string>
<key>ProductName</key>
<string>Mac OS X</string>
<key>ProductUserVisibleVersion</key>
<string>10.16</string>
<key>ProductVersion</key>
<string>10.16</string>
<key>iOSSupportVersion</key>
<string>14.2</string>
</dict>
</plist>
What am I missing?
This is the output from the same ipython session
In [3]: print(open("/System/Library/CoreServices/SystemVersion.plist").read())
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string>20B50</string>
<key>ProductCopyright</key>
<string>1983-2020 Apple Inc.</string>
<key>ProductName</key>
<string>Mac OS X</string>
<key>ProductUserVisibleVersion</key>
<string>10.16</string>
<key>ProductVersion</key>
<string>10.16</string>
<key>iOSSupportVersion</key>
<string>14.2</string>
</dict>
</plist>
In [4]: cat /System/Library/CoreServices/SystemVersion.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string>20B50</string>
<key>ProductCopyright</key>
<string>1983-2020 Apple Inc.</string>
<key>ProductName</key>
<string>macOS</string>
<key>ProductUserVisibleVersion</key>
<string>11.0.1</string>
<key>ProductVersion</key>
<string>11.0.1</string>
<key>iOSSupportVersion</key>
<string>14.2</string>
</dict>
</plist>
from Python's "platform.mac_ver()" reports incorrect MacOS version

No comments:
Post a Comment