Skip to content

Commit b9062bb

Browse files
committed
pythongh-129393: Make 'sys.platform' return "freebsd" only on FreeBSD without major version
1 parent 180ee43 commit b9062bb

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

Doc/library/sys.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14221422
AIX ``'aix'``
14231423
Android ``'android'``
14241424
Emscripten ``'emscripten'``
1425+
FreeBSD ``'freebsd'``
14251426
iOS ``'ios'``
14261427
Linux ``'linux'``
14271428
macOS ``'darwin'``
@@ -1432,12 +1433,12 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14321433

14331434
On Unix systems not listed in the table, the value is the lowercased OS name
14341435
as returned by ``uname -s``, with the first part of the version as returned by
1435-
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
1436-
when Python was built*. Unless you want to test for a specific system
1437-
version, it is therefore recommended to use the following idiom::
1436+
``uname -r`` appended, e.g. ``'sunos5'``, *at the time when Python was built*.
1437+
Unless you want to test for a specific system version, it is therefore
1438+
recommended to use the following idiom::
14381439

1439-
if sys.platform.startswith('freebsd'):
1440-
# FreeBSD-specific code here...
1440+
if sys.platform.startswith('sunos'):
1441+
# SunOS-specific code here...
14411442

14421443
.. versionchanged:: 3.3
14431444
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
14511452
On Android, :data:`sys.platform` now returns ``'android'`` rather than
14521453
``'linux'``.
14531454

1455+
.. versionchanged:: 3.14
1456+
On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
1457+
It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
1458+
14541459
.. seealso::
14551460

14561461
:data:`os.name` has a coarser granularity. :func:`os.uname` gives

Doc/whatsnew/3.14.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@ sys
649649
which only exists in specialized builds of Python, may now return objects
650650
from other interpreters than the one it's called in.
651651

652+
* On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
653+
It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
654+
652655
sys.monitoring
653656
--------------
654657

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
2+
It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.

configure

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ then
365365

366366
case $MACHDEP in
367367
aix*) MACHDEP="aix";;
368+
freebsd*) MACHDEP="freebsd";;
368369
linux-android*) MACHDEP="android";;
369370
linux*) MACHDEP="linux";;
370371
cygwin*) MACHDEP="cygwin";;

0 commit comments

Comments
 (0)