]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
add support for PyPy
authorBenjamin Peterson <benjamin@python.org>
Thu, 26 Mar 2009 19:09:21 +0000 (19:09 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 26 Mar 2009 19:09:21 +0000 (19:09 +0000)
Lib/platform.py
Lib/test/test_platform.py

index 7863821ccebdeedd289adf9bdf55a3306124d4cd..7a6f339147e55332d3879815d7422b3b98726d31 100755 (executable)
@@ -1270,6 +1270,11 @@ _ironpython_sys_version_parser = re.compile(
     '(?: \(([\d\.]+)\))?'
     ' on (.NET [\d\.]+)')
 
+_pypy_sys_version_parser = re.compile(
+    r'([\w.+]+)\s*'
+    '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
+    '\[PyPy [^\]]+\]?')
+
 _sys_version_cache = {}
 
 def _sys_version(sys_version=None):
@@ -1325,6 +1330,16 @@ def _sys_version(sys_version=None):
         version, buildno, builddate, buildtime, _ = match.groups()
         compiler = sys.platform
 
+    elif "PyPy" in sys_version:
+        # PyPy
+        name = "PyPy"
+        match = _pypy_sys_version_parser.match(sys_version)
+        if match is None:
+            raise ValueError("failed to parse PyPy sys.version: %s" %
+                             repr(sys_version))
+        version, buildno, builddate, buildtime = match.groups()
+        compiler = ""
+
     else:
         # CPython
         match = _sys_version_parser.match(sys_version)
index f10aa0698370ef45a79dae378dca0ab56524e534..0ca761c98f5bd0bc27be236ebe24713c08e1e824 100644 (file)
@@ -93,6 +93,11 @@ class PlatformTest(unittest.TestCase):
             :
                 ("Jython", "2.5.0", "trunk", "6107",
                  ('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"),
+            ("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]",
+             ('PyPy', 'trunk', '63378'), self.save_platform)
+            :
+                ("PyPy", "2.5.2", "trunk", "63378", ('63378', 'Mar 26 2009'),
+                 "")
             }
         for (version_tag, subversion, sys_platform), info in \
                 sys_versions.iteritems():