117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv# HG changeset patch
117724f21a94ff32f773af4c37be88fe0d2970e3~suv# User Ronald Oussoren <ronaldoussoren@mac.com>
117724f21a94ff32f773af4c37be88fe0d2970e3~suv# Date 1279889153 0
117724f21a94ff32f773af4c37be88fe0d2970e3~suv# Node ID e267ee9760bd14a8b4270e12af982c941fa7a67d
117724f21a94ff32f773af4c37be88fe0d2970e3~suv# Parent bdc069a1a721b28ad21849232bd5426dda871506
117724f21a94ff32f773af4c37be88fe0d2970e3~suvMerged revisions 83085 via svnmerge from
117724f21a94ff32f773af4c37be88fe0d2970e3~suvsvn+ssh://pythondev@svn.python.org/python/branches/release27-maint
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv................
117724f21a94ff32f773af4c37be88fe0d2970e3~suv r83085 | ronald.oussoren | 2010-07-23 13:41:00 +0100 (Fri, 23 Jul 2010) | 12 lines
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv Merged revisions 83075 via svnmerge from
117724f21a94ff32f773af4c37be88fe0d2970e3~suv svn+ssh://pythondev@svn.python.org/python/branches/py3k
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv ........
117724f21a94ff32f773af4c37be88fe0d2970e3~suv r83075 | ronald.oussoren | 2010-07-23 12:54:59 +0100 (Fri, 23 Jul 2010) | 5 lines
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv Fix for issue 7895. Avoid crashing the interpreter
117724f21a94ff32f773af4c37be88fe0d2970e3~suv when calling platform.mac_ver after calling os.fork by
117724f21a94ff32f773af4c37be88fe0d2970e3~suv reading from a system configuration file instead of
117724f21a94ff32f773af4c37be88fe0d2970e3~suv using OSX APIs.
117724f21a94ff32f773af4c37be88fe0d2970e3~suv ........
117724f21a94ff32f773af4c37be88fe0d2970e3~suv................
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suvdiff --git a/Lib/platform.py b/Lib/platform.py
117724f21a94ff32f773af4c37be88fe0d2970e3~suv--- Lib/platform.py
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+++ Lib/platform.py
117724f21a94ff32f773af4c37be88fe0d2970e3~suv@@ -562,28 +562,20 @@ def _bcd2str(bcd):
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv return hex(bcd)[2:]
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv-def mac_ver(release='',versioninfo=('','',''),machine=''):
117724f21a94ff32f773af4c37be88fe0d2970e3~suv-
117724f21a94ff32f773af4c37be88fe0d2970e3~suv- """ Get MacOS version information and return it as tuple (release,
117724f21a94ff32f773af4c37be88fe0d2970e3~suv- versioninfo, machine) with versioninfo being a tuple (version,
117724f21a94ff32f773af4c37be88fe0d2970e3~suv- dev_stage, non_release_version).
117724f21a94ff32f773af4c37be88fe0d2970e3~suv-
117724f21a94ff32f773af4c37be88fe0d2970e3~suv- Entries which cannot be determined are set to the paramter values
117724f21a94ff32f773af4c37be88fe0d2970e3~suv- which default to ''. All tuple entries are strings.
117724f21a94ff32f773af4c37be88fe0d2970e3~suv-
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+def _mac_ver_gestalt():
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ """
117724f21a94ff32f773af4c37be88fe0d2970e3~suv Thanks to Mark R. Levinson for mailing documentation links and
117724f21a94ff32f773af4c37be88fe0d2970e3~suv code examples for this function. Documentation for the
117724f21a94ff32f773af4c37be88fe0d2970e3~suv gestalt() API is available online at:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv http://www.rgaros.nl/gestalt/
117724f21a94ff32f773af4c37be88fe0d2970e3~suv-
117724f21a94ff32f773af4c37be88fe0d2970e3~suv """
117724f21a94ff32f773af4c37be88fe0d2970e3~suv # Check whether the version info module is available
117724f21a94ff32f773af4c37be88fe0d2970e3~suv try:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv import gestalt
117724f21a94ff32f773af4c37be88fe0d2970e3~suv import MacOS
117724f21a94ff32f773af4c37be88fe0d2970e3~suv except ImportError:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv- return release,versioninfo,machine
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return None
117724f21a94ff32f773af4c37be88fe0d2970e3~suv # Get the infos
117724f21a94ff32f773af4c37be88fe0d2970e3~suv sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa'))
117724f21a94ff32f773af4c37be88fe0d2970e3~suv # Decode the infos
117724f21a94ff32f773af4c37be88fe0d2970e3~suv@@ -619,6 +611,53 @@ def mac_ver(release='',versioninfo=('','
117724f21a94ff32f773af4c37be88fe0d2970e3~suv machine = {0x1: '68k',
117724f21a94ff32f773af4c37be88fe0d2970e3~suv 0x2: 'PowerPC',
117724f21a94ff32f773af4c37be88fe0d2970e3~suv 0xa: 'i386'}.get(sysa,'')
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return release,versioninfo,machine
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+def _mac_ver_xml():
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ fn = '/System/Library/CoreServices/SystemVersion.plist'
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ if not os.path.exists(fn):
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return None
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ try:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ import plistlib
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ except ImportError:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return None
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ pl = plistlib.readPlist(fn)
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ release = pl['ProductVersion']
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ versioninfo=('', '', '')
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ machine = os.uname()[4]
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ if machine == 'ppc':
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ # for compatibility with the gestalt based code
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ machine = 'PowerPC'
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return release,versioninfo,machine
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+def mac_ver(release='',versioninfo=('','',''),machine=''):
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ """ Get MacOS version information and return it as tuple (release,
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ versioninfo, machine) with versioninfo being a tuple (version,
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ dev_stage, non_release_version).
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ Entries which cannot be determined are set to the paramter values
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ which default to ''. All tuple entries are strings.
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ """
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ # First try reading the information from an XML file which should
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ # always be present
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ info = _mac_ver_xml()
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ if info is not None:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return info
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ # If that doesn't work for some reason fall back to reading the
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ # information using gestalt calls.
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ info = _mac_ver_gestalt()
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ if info is not None:
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ return info
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+
117724f21a94ff32f773af4c37be88fe0d2970e3~suv+ # If that also doesn't work return the default values
117724f21a94ff32f773af4c37be88fe0d2970e3~suv return release,versioninfo,machine
117724f21a94ff32f773af4c37be88fe0d2970e3~suv
117724f21a94ff32f773af4c37be88fe0d2970e3~suv def _java_getprop(name,default):