classification
Title: platform.system() should be "macosx" instead of "Darwin" on OSX
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Christian.Clauss, Justin.Cappos, jackdied, jaraco, lemburg, math_foo, nchammas, ronaldoussoren, vstinner
Priority: normal Keywords: patch

Created on 2010-02-03 22:40 by ronaldoussoren, last changed 2019-02-11 15:04 by ronaldoussoren. This issue is now closed.

Files
File name Uploaded Description Edit
aliased_system7850.patch math_foo, 2014-04-15 19:38 Adds aliased option to patform.system review
Messages (12)
msg98801 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-02-03 22:40
The output of platform.system() should IMO be "macosx" on OSX to ensure that platform.platform() is consistent with distutils.util.get_platform().

The same is true for sys.platform, although it is unclear how much code that would break.

There are two reasons for wanting these changes. First of all the values tend to end up at locations where less sophistated users might see them unless we're careful (tests for 'sys.platform' in scripts, platform names in distributions, ...) and 'darwin' is not obviously related to MacOSX unless you're already quite technical.   The other reason is slightly nit picking: "Darwin" is the name of the kernel and a stand-alone unix based on that, which MacOSX is the name of the entire system which includes much more beyond basic unix stuff.


BTW. I know why sys.platform is "darwin" on OSX, that doesn't mean I have to like it ;-)
msg99790 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2010-02-22 17:20
-1, my Ubuntu laptop says "linux2" and not "ubuntu." This would also be an incompatible change that would cause headaches with little benefit to balance it out.
msg99854 - (view) Author: Justin Cappos (Justin.Cappos) Date: 2010-02-22 22:15
Perhaps the right way to fix the problem without breaking code would be to propose a new function for platform which would return a 'newbie readable' string of the system type?
msg99860 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-02-22 22:35
platform.system() is a direct interface to platform.uname() which in return is an interface to the platform's uname() API, so the reasoning is much the same as for sys.platform on those platforms that do expose a uname() function (and command).

On Mac OS X, uname returns "Darwin".

What we can do, is add a new function parameter ''aliased'' (just like we have for platform.platform()) which then enables applying some aliasing to the returned uname() values.
msg216370 - (view) Author: Caelyn McAulay (math_foo) Date: 2014-04-15 19:38
Added aliased option to platform.system(). I used the same system_alias method as platform.platform(), so the result of the aliased version will match the system entry of the aliased platform.platform(). 

Added to platform.system unit test to test new functionality. Updated Documentation.

I am not sure if there is anywhere else I need to update the documentation to add this, i.e. if it needs a whatsnews entry (and if so, a pointer to docs on how to add to a whatsnews entry would be appreciated).
msg217885 - (view) Author: Christian Clauss (Christian.Clauss) * Date: 2014-05-04 19:35
assert sys.platform == platform.system().lower()

Should that always be True?  It is on Mac OS X but...

On iOS (Pythonista):
sys.platform ==> 'unknown'
platform.system() ==> 'Darwin'

https://docs.python.org/2/library/sys.html#sys.platform should be updated to provide the correct values for iOS and Android devices which now outnumber many of the other OSes listed.
msg217910 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2014-05-05 07:48
Caelyn: Thanks for the patch.

Some comments:

* Please use aliased=False instead of aliased=0 in the patch.
* It would be great if you could enhance the test a bit to actually check the return value. This would need a mock of the os.uname API for the test.
* Doc string "if "aliased" is true" should read "If aliased is true"
msg217911 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2014-05-05 07:49
Removing 2.7 as target, since this is a new feature.
msg259272 - (view) Author: Nicholas Chammas (nchammas) * Date: 2016-01-31 01:08
As of Python 3.5.1 [0], it looks like

1) the `aliased` and `terse` parameters of `platform.platform()` are documented to take integers instead of booleans (contrary to what Marc-Andre requested), and 

2) calling `platform.platform()` with `aliased` set to 1 or True still returns "Darwin" on OS X.

Is this by design?

[0] https://docs.python.org/3.5/library/platform.html#platform.platform
msg335218 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2019-02-11 14:05
This issue now needs to consider that Mac OS X was renamed to macOS.
msg335219 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-02-11 14:12
I suggest to close this issue.

@Ronald: Or do you think that something should still be done on macOS in the platform module?

This issue looks like a duplicate of bpo-35516. It has been decided that platform.system_alias() doesn't replace Darwin with macOS (it's now explained in a comment: see my commit 60875db2f67815d7d181c552bfac59e8c97619e3).

I modified platform.platform() to return "macOS" rather than "darwin" on macOS: "bpo-35344: platform.platform() uses mac_ver() on macOS (GH-10780)" (commit ea0ca218b0c28b2af2b1f6a5d3383569de7fc2c1).
msg335228 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2019-02-11 15:04
This issue can be closed. Status quo wins due to backward compatibility concerns.

BTW. The primary reason for proposing "macosx" as the return value for platform.system() is that the platform name as used in egg files (at the time, now wheels) is "macosx". That, and having two clearly different platforms with the same name (macOS and iOS).

And one final note: I definitely wouldn't mind having an API in platform that returns the marketing name and version of the current system (like mac_ver and linux_distribution).  But that API cannot be system_alias because its API contract does not give it access to enough information. Such an API could be designed in a new issue.
History
Date User Action Args
2019-02-11 15:04:59ronaldoussorensetstatus: open -> closed
resolution: rejected
messages: + msg335228

stage: resolved
2019-02-11 14:12:04vstinnersetnosy: + vstinner
messages: + msg335219
2019-02-11 14:05:39jaracosetnosy: + jaraco
messages: + msg335218
2016-01-31 01:08:41nchammassetnosy: + nchammas
messages: + msg259272
2014-05-05 07:49:29lemburgsetmessages: + msg217911
versions: - Python 2.7
2014-05-05 07:48:01lemburgsetmessages: + msg217910
2014-05-04 19:35:48Christian.Clausssetnosy: + Christian.Clauss
messages: + msg217885
2014-04-15 19:38:31math_foosetfiles: + aliased_system7850.patch

nosy: + math_foo
messages: + msg216370

keywords: + patch
2010-02-22 22:35:03lemburgsetmessages: + msg99860
2010-02-22 22:25:49brian.curtinsetnosy: + lemburg
2010-02-22 22:15:13Justin.Cappossetnosy: + Justin.Cappos
messages: + msg99854
2010-02-22 17:20:52jackdiedsetnosy: + jackdied
messages: + msg99790
2010-02-03 22:40:10ronaldoussorencreate