Skip to content

Commit 9d949f7

Browse files
aixtoolsvstinner
authored andcommitted
bpo-36588: On AIX, remove major version from sys.platform (GH-12787)
On AIX, sys.platform doesn't contain the major version anymore. Always return 'aix', instead of 'aix3' .. 'aix7'. Since older Python versions include the version number, it is recommended to always use sys.platform.startswith('aix').
1 parent 9b8314c commit 9d949f7

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

Doc/library/sys.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ always available.
10141014
This string contains a platform identifier that can be used to append
10151015
platform-specific components to :data:`sys.path`, for instance.
10161016

1017-
For Unix systems, except on Linux, this is the lowercased OS name as
1017+
For Unix systems, except on Linux and AIX, this is the lowercased OS name as
10181018
returned by ``uname -s`` with the first part of the version as returned by
10191019
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
10201020
when Python was built*. Unless you want to test for a specific system
@@ -1024,12 +1024,15 @@ always available.
10241024
# FreeBSD-specific code here...
10251025
elif sys.platform.startswith('linux'):
10261026
# Linux-specific code here...
1027+
elif sys.platform.startswith('aix'):
1028+
# AIX-specific code here...
10271029

10281030
For other systems, the values are:
10291031

10301032
================ ===========================
10311033
System ``platform`` value
10321034
================ ===========================
1035+
AIX ``'aix'``
10331036
Linux ``'linux'``
10341037
Windows ``'win32'``
10351038
Windows/Cygwin ``'cygwin'``
@@ -1042,6 +1045,12 @@ always available.
10421045
older Python versions include the version number, it is recommended to
10431046
always use the ``startswith`` idiom presented above.
10441047

1048+
.. versionchanged:: 3.8
1049+
On AIX, :attr:`sys.platform` doesn't contain the major version anymore.
1050+
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``. Since
1051+
older Python versions include the version number, it is recommended to
1052+
always use the ``startswith`` idiom presented above.
1053+
10451054
.. seealso::
10461055

10471056
:attr:`os.name` has a coarser granularity. :func:`os.uname` gives

Doc/whatsnew/3.8.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,11 @@ Changes in Python behavior
700700
raised when getting the attribute from the type dictionary are no longer
701701
ignored. (Contributed by Serhiy Storchaka in :issue:`35459`.)
702702

703+
* On AIX, :attr:`sys.platform` doesn't contain the major version anymore.
704+
It is always ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since
705+
older Python versions include the version number, it is recommended to
706+
always use the ``sys.platform.startswith('aix')``.
707+
(Contributed by M. Felt in :issue:`36588`.)
703708

704709
Changes in the Python API
705710
-------------------------
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
On AIX, :attr:`sys.platform` doesn't contain the major version anymore.
2+
Always return ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since
3+
older Python versions include the version number, it is recommended to
4+
always use ``sys.platform.startswith('aix')``.
5+
Contributed by M. Felt.

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3281,6 +3281,7 @@ then
32813281
MACHDEP="$ac_md_system$ac_md_release"
32823282

32833283
case $MACHDEP in
3284+
aix*) MACHDEP="aix";;
32843285
linux*) MACHDEP="linux";;
32853286
cygwin*) MACHDEP="cygwin";;
32863287
darwin*) MACHDEP="darwin";;
@@ -10199,7 +10200,6 @@ fi
1019910200

1020010201

1020110202

10202-
1020310203
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1020410204
if test -n "$ac_tool_prefix"; then
1020510205
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ then
404404
MACHDEP="$ac_md_system$ac_md_release"
405405

406406
case $MACHDEP in
407+
aix*) MACHDEP="aix";;
407408
linux*) MACHDEP="linux";;
408409
cygwin*) MACHDEP="cygwin";;
409410
darwin*) MACHDEP="darwin";;

0 commit comments

Comments
 (0)