Opened 10 months ago

#6746 enhancement new

Improve Jython platform detection in t.python.runtime

Reported by: thijs Owned by: oberstet
Priority: low Milestone:
Component: core Keywords:
Cc: thijs Branch:
Author: Launchpad Bug:


Jython identifies itself as "java" on any platform, eg.

Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52) 
[OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_27
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> == 'java' and hasattr(os, '_name')
>>> os._name
>>> from twisted.python.runtime import platform, platformType
>>> platform.isWindows()
>>> platform.isLinux()
>>> platform.isKnown()
>>> platform.getType()

The session above comes from an Ubuntu 12.10 system with the latest Jython 2.7b1 release. platform.isLinux() should return True but that function incorrectly check if it's Jython *running on Linux*. It only checks if the platform name starts with 'linux' which is False on Jython (it's always 'java' no matter the platform). Same issue is present in isMacOSX, isWindows etc.

Originally reported in #3413 by oberstet that also includes a possible fix.

Change History (0)

Note: See TracTickets for help on using tickets.