[Jython-checkins] jython: Avoid importing platform and use to sys.platform.startswith("java")

frank.wierzbicki jython-checkins at python.org
Tue May 22 19:04:19 CEST 2012


http://hg.python.org/jython/rev/a2cf580d1f2d
changeset:   6663:a2cf580d1f2d
user:        Frank Wierzbicki <fwierzbicki at gmail.com>
date:        Tue May 22 10:01:30 2012 -0700
summary:
  Avoid importing platform and use to sys.platform.startswith("java")

files:
  Lib/SimpleHTTPServer.py |  3 +--
  Lib/site.py             |  4 +---
  Lib/tempfile.py         |  7 +------
  3 files changed, 3 insertions(+), 11 deletions(-)


diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -11,7 +11,6 @@
 __all__ = ["SimpleHTTPRequestHandler"]
 
 import os
-import platform
 import posixpath
 import BaseHTTPServer
 import urllib
@@ -133,7 +132,7 @@
         length = f.tell()
         f.seek(0)
         self.send_response(200)
-        if not platform.python_implementation() == "Jython":
+        if not sys.platform.startswith("java"):
             encoding = sys.getfilesystemencoding()
             self.send_header("Content-type", "text/html; charset=%s" % encoding)
         self.send_header("Content-Length", str(length))
diff --git a/Lib/site.py b/Lib/site.py
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -63,9 +63,7 @@
 import __builtin__
 import traceback
 
-import platform as _platform
-
-_is_jython = _platform.python_implementation() == "Jython"
+_is_jython = sys.platform.startswith("java")
 if _is_jython:
     _ModuleType = type(os)
 
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -33,11 +33,6 @@
 import errno as _errno
 from random import Random as _Random
 
-import platform as _platform
-
-_is_jython = _platform.python_implementation() == "Jython"
-
-
 try:
     from cStringIO import StringIO as _StringIO
 except ImportError:
@@ -127,7 +122,7 @@
 
     @property
     def rng(self):
-        if _is_jython:
+        if _os.sys.platform.startswith("java"):
             #A JVM run cannot determine or change its pid so dummy this.
             cur_pid = 1
         else:

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list