From 2021d40faa8424d7064c66cde03ea62f63150467 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Thu, 11 Apr 2019 14:40:24 +0000 Subject: [PATCH 1/4] On AIX, remove the major version in sys.platform --- Doc/library/sys.rst | 10 +++++++++- Doc/whatsnew/3.8.rst | 10 ++++++++++ .../2019-04-11-14-36-55.bpo-36588.wejLoC.rst | 4 ++++ configure.ac | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 52026f6a2bce38..3bf423e17f5bcf 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1014,7 +1014,7 @@ 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, except on Linux, this is the lowercased OS name as + For Unix systems, except on Linux and AIX, 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 ``'freebsd8'``, *at the time when Python was built*. Unless you want to test for a specific system @@ -1030,6 +1030,7 @@ always available. ================ =========================== System ``platform`` value ================ =========================== + AIX ``'aix'`` Linux ``'linux'`` Windows ``'win32'`` Windows/Cygwin ``'cygwin'`` @@ -1042,6 +1043,13 @@ always available. older Python versions include the version number, it is recommended to always use the ``startswith`` idiom presented above. + .. versionchanged:: 3.8 + On AIX, :attr:`sys.platform` doesn't contain the major version anymore. + already uses the ``startswith`` idiom discussed above no changes to + existing code is expected. Remember, this is the version of AIX Python3 + was built on, not running on. To get the version you are running on, + e.g., 6 or 7, use ``os.uname()[3]`` + .. seealso:: :attr:`os.name` has a coarser granularity. :func:`os.uname` gives diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index aa75beeabe70e4..19e6339a055147 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -679,6 +679,16 @@ Porting to Python 3.8 This section lists previously described changes and other bugfixes that may require changes to your code. +Porting Python code +------------------- + XXX :issue:`36588`: On AIX, sys.platform doesn't contain the major version + anymore. It is now always 'aix', instead of 'aix3', 'aix4', ..., 'aix7' + depending on the AIX version used to build Python. + Replace sys.platform == 'aixX' with sys.platform == 'aix' or + with sys.platform.startswith('aix'). + Code using sys.platform.startswith('aix') will work without any change. + + (Contributed by M. Felt) Changes in Python behavior -------------------------- diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst new file mode 100644 index 00000000000000..52a120764dac94 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst @@ -0,0 +1,4 @@ +On AIX, remove the major version in sys.platform +It is now always 'aix', instead of 'aix3', 'aix4', ..., 'aix7' +that reflected the AIX version used to build Python. +Contributed by M. Felt diff --git a/configure.ac b/configure.ac index 73ee71c6d24997..9632addc817e4d 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";; From 540f92222532b4dbb41ae8198722ffb37f0a27e5 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Thu, 11 Apr 2019 15:24:44 +0000 Subject: [PATCH 2/4] add new configure --- configure | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/configure b/configure index d0ef8a601b287b..da0ae8196a629d 100755 --- a/configure +++ b/configure @@ -783,7 +783,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -895,7 +894,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1148,15 +1146,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1294,7 +1283,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1447,7 +1436,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -3293,6 +3281,7 @@ then MACHDEP="$ac_md_system$ac_md_release" case $MACHDEP in + aix*) MACHDEP="aix";; linux*) MACHDEP="linux";; cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; @@ -10211,7 +10200,6 @@ fi - if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. From ac0e41bb1a72cc00b741ba791fc3b7f0785fe9d7 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Thu, 11 Apr 2019 18:05:18 +0000 Subject: [PATCH 3/4] Less complex text --- Doc/library/sys.rst | 9 +++++---- Doc/whatsnew/3.8.rst | 16 +++++----------- .../2019-04-11-14-36-55.bpo-36588.wejLoC.rst | 9 +++++---- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 3bf423e17f5bcf..591972e9b783a0 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1024,6 +1024,8 @@ always available. # FreeBSD-specific code here... elif sys.platform.startswith('linux'): # Linux-specific code here... + elif sys.platform.startswith('aix'): + # AIX-specific code here... For other systems, the values are: @@ -1045,10 +1047,9 @@ always available. .. versionchanged:: 3.8 On AIX, :attr:`sys.platform` doesn't contain the major version anymore. - already uses the ``startswith`` idiom discussed above no changes to - existing code is expected. Remember, this is the version of AIX Python3 - was built on, not running on. To get the version you are running on, - e.g., 6 or 7, use ``os.uname()[3]`` + It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``. Since + older Python versions include the version number, it is recommended to + always use the ``startswith`` idiom presented above. .. seealso:: diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 19e6339a055147..f37f5e0ff1a034 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -679,17 +679,6 @@ Porting to Python 3.8 This section lists previously described changes and other bugfixes that may require changes to your code. -Porting Python code -------------------- - XXX :issue:`36588`: On AIX, sys.platform doesn't contain the major version - anymore. It is now always 'aix', instead of 'aix3', 'aix4', ..., 'aix7' - depending on the AIX version used to build Python. - Replace sys.platform == 'aixX' with sys.platform == 'aix' or - with sys.platform.startswith('aix'). - Code using sys.platform.startswith('aix') will work without any change. - - (Contributed by M. Felt) - Changes in Python behavior -------------------------- @@ -710,6 +699,11 @@ Changes in Python behavior raised when getting the attribute from the type dictionary are no longer ignored. (Contributed by Serhiy Storchaka in :issue:`35459`.) +* On AIX, :attr:`sys.platform` doesn't contain the major version anymore. + It is always ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since + older Python versions include the version number, it is recommended to + always use the ``sys.platform.startswith('aix')``. + (Contributed by M. Felt in :issue:`36588`:.) Changes in the Python API ------------------------- diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst index 52a120764dac94..e8218f37b442c5 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst @@ -1,4 +1,5 @@ -On AIX, remove the major version in sys.platform -It is now always 'aix', instead of 'aix3', 'aix4', ..., 'aix7' -that reflected the AIX version used to build Python. -Contributed by M. Felt +On AIX, :attr:`sys.platform` doesn't contain the major version anymore. +It is always ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since +older Python versions include the version number, it is recommended to +always use the ``sys.platform.startswith('aix')``. +Contributed by M. Felt in :issue:`36588`:. From 482e16616fcb4964c17140542f94d8b89afc9553 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Fri, 12 Apr 2019 08:57:14 +0000 Subject: [PATCH 4/4] Text corrections --- Doc/whatsnew/3.8.rst | 3 ++- .../2019-04-11-14-36-55.bpo-36588.wejLoC.rst | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index f37f5e0ff1a034..bf28e5ff4b06c2 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -679,6 +679,7 @@ Porting to Python 3.8 This section lists previously described changes and other bugfixes that may require changes to your code. + Changes in Python behavior -------------------------- @@ -703,7 +704,7 @@ Changes in Python behavior It is always ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since older Python versions include the version number, it is recommended to always use the ``sys.platform.startswith('aix')``. - (Contributed by M. Felt in :issue:`36588`:.) + (Contributed by M. Felt in :issue:`36588`.) Changes in the Python API ------------------------- diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst index e8218f37b442c5..77d2fa4e299b3e 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2019-04-11-14-36-55.bpo-36588.wejLoC.rst @@ -1,5 +1,5 @@ On AIX, :attr:`sys.platform` doesn't contain the major version anymore. -It is always ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since +Always return ``'aix'``, instead of ``'aix3'`` .. ``'aix7'``. Since older Python versions include the version number, it is recommended to -always use the ``sys.platform.startswith('aix')``. -Contributed by M. Felt in :issue:`36588`:. +always use ``sys.platform.startswith('aix')``. +Contributed by M. Felt.