]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129393: Make 'sys.platform' return "freebsd" only on FreeBSD (#129394)
authorMichael Osipov <michael.osipov@innomotics.com>
Fri, 31 Jan 2025 09:02:45 +0000 (10:02 +0100)
committerGitHub <noreply@github.com>
Fri, 31 Jan 2025 09:02:45 +0000 (10:02 +0100)
Make 'sys.platform' return "freebsd" only on FreeBSD without major version.

Doc/library/sys.rst
Doc/whatsnew/3.14.rst
Misc/NEWS.d/next/Core_and_Builtins/2025-01-28-10-26-04.gh-issue-129393.0eICq6.rst [new file with mode: 0644]
configure
configure.ac

index 151fd60532048af0d9402b695e836ab6214d9831..5a09623571331949d68e8b89db6f0b69bb7d0894 100644 (file)
@@ -1422,6 +1422,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
    AIX              ``'aix'``
    Android          ``'android'``
    Emscripten       ``'emscripten'``
+   FreeBSD          ``'freebsd'``
    iOS              ``'ios'``
    Linux            ``'linux'``
    macOS            ``'darwin'``
@@ -1432,12 +1433,12 @@ always available. Unless explicitly noted otherwise, all variables are read-only
 
    On Unix systems not listed in the table, the value 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
-   version, it is therefore recommended to use the following idiom::
+   ``uname -r`` appended, e.g. ``'sunos5'``, *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('freebsd'):
-          # FreeBSD-specific code here...
+      if sys.platform.startswith('sunos'):
+          # SunOS-specific code here...
 
    .. versionchanged:: 3.3
       On Linux, :data:`sys.platform` doesn't contain the major version anymore.
@@ -1451,6 +1452,10 @@ always available. Unless explicitly noted otherwise, all variables are read-only
       On Android, :data:`sys.platform` now returns ``'android'`` rather than
       ``'linux'``.
 
+   .. versionchanged:: 3.14
+      On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
+      It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
+
    .. seealso::
 
       :data:`os.name` has a coarser granularity.  :func:`os.uname` gives
index 8d4cb94ae2d805a3a4fe54beb668f5976105a60f..484e306335829aee18a434e47fc02eccda6948a7 100644 (file)
@@ -649,6 +649,9 @@ sys
   which only exists in specialized builds of Python, may now return objects
   from other interpreters than the one it's called in.
 
+* On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
+  It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
+
 sys.monitoring
 --------------
 
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-01-28-10-26-04.gh-issue-129393.0eICq6.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-01-28-10-26-04.gh-issue-129393.0eICq6.rst
new file mode 100644 (file)
index 0000000..e36e6f5
--- /dev/null
@@ -0,0 +1,2 @@
+On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
+It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
index 885c2cf7828d6c6404e055bf8c8d7ec7a2ca0299..3eb787f788bfb957d0548adcafafd71a40ab3af6 100755 (executable)
--- a/configure
+++ b/configure
@@ -4132,6 +4132,7 @@ then
 
     case $MACHDEP in
        aix*) MACHDEP="aix";;
+       freebsd*) MACHDEP="freebsd";;
        linux-android*) MACHDEP="android";;
        linux*) MACHDEP="linux";;
        cygwin*) MACHDEP="cygwin";;
index f89a0801948ca53b88ffaccc3b3919392b59bab3..c0130b8082cd8abc3d649f308c73198e403b8380 100644 (file)
@@ -365,6 +365,7 @@ then
 
     case $MACHDEP in
        aix*) MACHDEP="aix";;
+       freebsd*) MACHDEP="freebsd";;
        linux-android*) MACHDEP="android";;
        linux*) MACHDEP="linux";;
        cygwin*) MACHDEP="cygwin";;