From 8256242b30005b8a1b52e79149558ad36f1307d6 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 5 Mar 2011 21:09:22 +0100 Subject: Adapt platform and test_platform to the build identification changes. --- Lib/platform.py | 4 +++- Lib/test/test_platform.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 7fba143..780301d 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1373,7 +1373,9 @@ def _sys_version(sys_version=None): name = 'CPython' builddate = builddate + ' ' + buildtime - if hasattr(sys, 'subversion'): + if hasattr(sys, '_mercurial'): + _, branch, revision = sys._mercurial + elif hasattr(sys, 'subversion'): # sys.subversion was added in Python 2.5 _, branch, revision = sys.subversion else: diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 4fd286a..2f688a4 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -51,11 +51,13 @@ class PlatformTest(unittest.TestCase): def setUp(self): self.save_version = sys.version self.save_subversion = sys.subversion + self.save_mercurial = sys._mercurial self.save_platform = sys.platform def tearDown(self): sys.version = self.save_version sys.subversion = self.save_subversion + sys._mercurial = self.save_mercurial sys.platform = self.save_platform def test_sys_version(self): @@ -103,10 +105,12 @@ class PlatformTest(unittest.TestCase): sys_versions.items(): sys.version = version_tag if subversion is None: + if hasattr(sys, "_mercurial"): + del sys._mercurial if hasattr(sys, "subversion"): del sys.subversion else: - sys.subversion = subversion + sys._mercurial = subversion if sys_platform is not None: sys.platform = sys_platform self.assertEqual(platform.python_implementation(), info[0]) -- cgit v0.12