This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: change sys.platform() to just "aix" for AIX
Type: Stage: resolved
Components: Build Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Michael.Felt, vstinner
Priority: normal Keywords: patch

Created on 2019-04-10 15:04 by Michael.Felt, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12787 merged Michael.Felt, 2019-04-11 15:27
Messages (11)
msg339869 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-04-10 15:04
This is something that probably shouts - boring - but back in 2012 it was a hot topic for linux2 and linux3.

Maybe - as far back as 1996 (when AIX4 was new) "aix3" and "aix4" made sense. Whether that is true, or not - is pointless these days - for Python3.

In the python code I have reviewed - for various reasons - I have never seen any code with "sys.platform() == "aixX" (where X is any of 5, 6, 7).

There was a reference to "aix3" and "aix4" in setup.py (recently removed, and there is no replacement for aix5, aix6, or aix7 - not needed!)

What I mostly see is sys.platform.startswith("aix"). The other form of the same test is sys.platform[:3] == 'aix'

sys.platform is "build" related, e.g., potentially bound to libc issues. Even if this was the case (AIX offers since 2007 - official binary compatibility from old to new (when libc is dynamically linked, not static linked), was "unofficial" for aix3 and aix4).

Yes, I am sure there are arguments along the line of "why change" since we have been updating it - always, and/or the documentation says so.

linux2 had to stay, because there was known code that compared with linux2 (and that code was having problems when python was built on linux3 - hence the change to make sys.platform return linux2 for all Python3.2 and younger).

FYI: in Cpython (master) there are no references to "aixX".

All the references there are (in .py) are:

michael@x071:[/data/prj/python/git/cpython-master]find . -name \*.py | xargs egrep "[\"']aix"
./Lib/asyncio/unix_events.py:        if is_socket or (is_fifo and not sys.platform.startswith("aix")):
./Lib/ctypes/__init__.py:        if _sys.platform.startswith("aix"):
./Lib/ctypes/util.py:elif sys.platform.startswith("aix"):
./Lib/ctypes/util.py:        elif sys.platform.startswith("aix"):
./Lib/distutils/command/build_ext.py:        elif sys.platform[:3] == 'aix':
./Lib/distutils/util.py:    elif osname[:3] == "aix":
./Lib/sysconfig.py:    elif osname[:3] == "aix":
./Lib/test/test_asyncio/test_events.py:    if sys.platform.startswith("aix"):
./Lib/test/test_faulthandler.py:    @unittest.skipIf(sys.platform.startswith('aix'),
./Lib/test/test_strftime.py:        or sys.platform.startswith(("aix", "sunos", "solaris"))):
./Lib/test/test_strptime.py:    @unittest.skipIf(sys.platform.startswith('aix'),
./Lib/test/test_locale.py:    @unittest.skipIf(sys.platform.startswith('aix'),
./Lib/test/test_locale.py:    @unittest.skipIf(sys.platform.startswith('aix'),
./Lib/test/test_fileio.py:                       not sys.platform.startswith(('sunos', 'aix')):
./Lib/test/test_tools/test_i18n.py:    @unittest.skipIf(sys.platform.startswith('aix'),
./Lib/test/test_wait4.py:        if sys.platform.startswith('aix'):
./Lib/test/test_c_locale_coercion.py:elif sys.platform.startswith("aix"):
./Lib/test/test_shutil.py:AIX = sys.platform[:3] == 'aix'
./Lib/test/test_utf8_mode.py:        elif sys.platform.startswith("aix"):

I'll write the patch - if I recall it should be a one-liner in configure.ac, but I think some discussion (or blessing) first is appropriate.

Maybe even review whether other platforms no longer rely on the X for the platform.

Hoping this helps!
msg339870 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-10 15:05
I like the idea. Would you like to propose a patch? I suggest to only make such change in Python 3.8 and properly document it.
msg339872 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-04-10 15:54
On 10/04/2019 17:05, STINNER Victor wrote:
> STINNER Victor <vstinner@redhat.com> added the comment:
>
> I like the idea. Would you like to propose a patch? I suggest to only make such change in Python 3.8 and properly document it.
>
> ----------
> nosy: +vstinner
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue36588>
> _______________________________________
>
If I understand correctly, the change should be quite simple:

diff --git a/configure.ac b/configure.ac
index 73ee71c..9632add 100644
--- a/configure.ac
+++ b/configure.ac
@@ -404,6 +404,7 @@ then
     MACHDEP="$ac_md_system$ac_md_release"

     case $MACHDEP in
+       aix*) MACHDEP="aix";;
        linux*) MACHDEP="linux";;
        cygwin*) MACHDEP="cygwin";;
        darwin*) MACHDEP="darwin";;

However, I am less familiar with (where) the appropriate documentation
is. A pointer to the documentation is appreciated.
msg339895 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-10 22:09
> However, I am less familiar with (where) the appropriate documentation is. A pointer to the documentation is appreciated.

It would be nice to add a note to:

* https://docs.python.org/dev/whatsnew/3.8.html#changes-in-the-python-api
* https://docs.python.org/dev/library/sys.html#sys.platform

In the source code, there are the files:

* Doc/whatsnew/3.8.rst
* Doc/library/sys.rst
msg339983 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-04-11 15:23
Was:
root@x064:[/data/prj/python/python3-3.8]./python
Python 3.8.0a3+ (heads/bpo-28009-2-dirty:2fb2bc81c3, Apr 11 2019, 07:09:55) [C] on aix6
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.platform
'aix6'
>>> import os
>>> os.uname()[3]
'7'

./python ../git/python3-3.8/Tools/scripts/patchcheck.py
Getting base branch for PR ... origin/master
Getting the list of files that have been added/changed ... 6 files
Fixing Python file whitespace ... 0 files
Fixing C file whitespace ... 0 files
Fixing docs whitespace ... 0 files
Docs modified ... yes
Misc/ACKS updated ... NO
Misc/NEWS.d updated with `blurb` ... yes
configure regenerated ... yes
pyconfig.h.in regenerated ... no

On system I built on:
root@x066:[/data/prj/python/python3-3.8]./python
Python 3.8.0a3+ (heads/bpo-36588-aix-platform-dirty:2021d40faa, Apr 11 2019, 15:16:05) [C] on aix
Type "help", "copyright", "credits" or "license" for more information.
>>> import os,sys
>>> sys.platform
'aix'
>>> os.uname()[3]
'6'

And on AIX7 system:
root@x064:[/data/prj/python/python3-3.8]./python
Python 3.8.0a3+ (heads/bpo-36588-aix-platform-dirty:2021d40faa, Apr 11 2019, 15:16:05) [C] on aix
Type "help", "copyright", "credits" or "license" for more information.
>>> import os,sys
>>> sys.platform
'aix'
>>> os.uname()[3]
'7'
msg340048 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-12 14:15
New changeset 9d949f7796da612f1b588d18c6f041376992a9fc by Victor Stinner (Michael Felt) in branch 'master':
bpo-36588: On AIX, remove major version from sys.platform (GH-12787)
https://github.com/python/cpython/commit/9d949f7796da612f1b588d18c6f041376992a9fc
msg340049 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-12 14:16
Do you want to work on a change to replace sys.platform.startswith("aix") to cleanup the stdlib and tests? Not sure if it's needed :-) It's up to you.
msg340061 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-04-12 15:28
On 12/04/2019 16:16, STINNER Victor wrote:
> STINNER Victor <vstinner@redhat.com> added the comment:
>
> Do you want to work on a change to replace sys.platform.startswith("aix") to cleanup the stdlib and tests? Not sure if it's needed :-) It's up to you.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue36588>
> _______________________________________
>
Sure. I'll do that. I shoul open an issue along the lines of "AIX:
cleanup stdlib and tests and how sys.platform is utilized".

But, should I just continue standard practice (sys.platform), or would
this be a moment to move towards platform.system() (i.e., set the
example to be to use "run-time" rather than "build-time").

Michael
msg340064 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-12 15:34
> But, should I just continue standard practice (sys.platform), or would
> this be a moment to move towards platform.system() (i.e., set the
> example to be to use "run-time" rather than "build-time").

Oh, now I'm confused :-) I checked the Python test suite: some tests use sys.platform == "linux" or sys.platform in ("linux", ...), some tests uses sys.platform.startswith("linux").

In case of doubt, I suggest to do nothing :-) Leave the code unchanged :-)
msg340112 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-04-12 21:16
On 12/04/2019 17:34, STINNER Victor wrote:
> STINNER Victor <vstinner@redhat.com> added the comment:
>
>> But, should I just continue standard practice (sys.platform), or would
>> this be a moment to move towards platform.system() (i.e., set the
>> example to be to use "run-time" rather than "build-time").
> Oh, now I'm confused :-) I checked the Python test suite: some tests use sys.platform == "linux" or sys.platform in ("linux", ...), some tests uses sys.platform.startswith("linux").
>
> In case of doubt, I suggest to do nothing :-) Leave the code unchanged :-)

Agreed, in case of doubt - leave alone (never change a winning team).

And, to make it a short reply - I'll get started, and we see where it
leads us.

Michael

>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue36588>
> _______________________________________
>
msg340156 - (view) Author: Michael Felt (Michael.Felt) * Date: 2019-04-13 12:28
On 12/04/2019 23:16, Michael Felt wrote:
> Agreed, in case of doubt - leave alone (never change a winning team).
>
> And, to make it a short reply - I'll get started, and we see where it
> leads us.

I opened issue36624 (https://bugs.python.org/issue36624) - before I
"take off", some comments/discussion on what is desirable and achievable
would be welcome.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80769
2019-04-13 12:28:44Michael.Feltsetmessages: + msg340156
2019-04-12 21:16:21Michael.Feltsetmessages: + msg340112
2019-04-12 15:34:27vstinnersetmessages: + msg340064
2019-04-12 15:28:04Michael.Feltsetmessages: + msg340061
2019-04-12 14:16:41vstinnersetmessages: + msg340049
2019-04-12 14:16:10vstinnersetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 3.9
2019-04-12 14:15:35vstinnersetmessages: + msg340048
2019-04-11 15:27:40Michael.Feltsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12714
2019-04-11 15:23:38Michael.Feltsetmessages: + msg339983
2019-04-10 22:09:28vstinnersetmessages: + msg339895
2019-04-10 15:54:50Michael.Feltsetmessages: + msg339872
2019-04-10 15:05:58vstinnersetnosy: + vstinner
messages: + msg339870
2019-04-10 15:04:50Michael.Feltcreate