Fix for issue 7895. Avoid crashing the interpreter

when calling platform.mac_ver after calling os.fork by
reading from a system configuration file instead of
using OSX APIs.
This commit is contained in:
Ronald Oussoren 2010-07-23 11:54:59 +00:00
parent c3960c28b0
commit e186e384f4
3 changed files with 71 additions and 11 deletions

View file

@ -194,6 +194,25 @@ class PlatformTest(unittest.TestCase):
else:
self.assertEquals(res[2], 'PowerPC')
@unittest.skipUnless(sys.platform == 'darwin', "OSX only test")
def test_mac_ver_with_fork(self):
# Issue7895: platform.mac_ver() crashes when using fork without exec
#
# This test checks that the fix for that issue works.
#
pid = os.fork()
if pid == 0:
# child
info = platform.mac_ver()
os._exit(0)
else:
# parent
cpid, sts = os.waitpid(pid, 0)
self.assertEquals(cpid, pid)
self.assertEquals(sts, 0)
def test_dist(self):
res = platform.dist()