[issue12326] Linux 3: code should avoid using sys.platform == 'linux2'
STINNER Victor
report at bugs.python.org
Tue Aug 23 00:39:18 CEST 2011
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
Something like:
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -699,20 +699,21 @@ always available.
This string contains a platform identifier that can be used to append
platform-specific components to :data:`sys.path`, for instance.
- For Unix systems, this is the lowercased OS name as returned by ``uname -s``
- with the first part of the version as returned by ``uname -r`` appended,
- e.g. ``'sunos5'`` or ``'linux2'``, *at the time when Python was built*.
- Unless you want to test for a specific system version, it is therefore
- recommended to use the following idiom::
+ For Unix systems, except on Linux, this is the lowercased OS name as
+ returned by ``uname -s`` with the first part of the version as returned by
+ ``uname -r`` appended, e.g. ``'sunos5'`` or ``'linux2'``, *at the time when
+ Python was built*. Unless you want to test for a specific system version,
+ it is therefore recommended to use the following idiom::
- if sys.platform.startswith('linux'):
- # Linux-specific code here...
+ if sys.platform.startswith('freebsd'):
+ # Freebsd-specific code here...
For other systems, the values are:
================ ===========================
System :data:`platform` value
================ ===========================
+ Linux ``'linux2'``
Windows ``'win32'``
Windows/Cygwin ``'cygwin'``
Mac OS X ``'darwin'``
?
I don't think that I need a :versionchanged:`2.7.3`.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12326>
_______________________________________
More information about the Python-bugs-list
mailing list