Skip to content

Commit 659e573

Browse files
committed
Move migration guide to What's New docs
1 parent 0d30914 commit 659e573

File tree

2 files changed

+63
-46
lines changed

2 files changed

+63
-46
lines changed

Doc/library/sys.rst

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,14 @@ always available. Unless explicitly noted otherwise, all variables are read-only
2525
.. availability:: Unix.
2626

2727
.. versionchanged:: next
28-
A deprecation warning will be emitted if the :data:`sys.abiflags` member
29-
is accessed on Windows before Python 3.16.
30-
For example:
31-
32-
.. code-block:: python
33-
34-
>>> import sys
35-
>>> getattr(sys, 'abiflags', None) # on Windows
36-
<python-input-1>:1: DeprecationWarning: sys.abiflags will be set to a meaningful value on all platforms ...
37-
>>> hasattr(sys, 'abiflags') # on Windows
38-
<python-input-2>:1: DeprecationWarning: sys.abiflags will be set to a meaningful value on all platforms ...
39-
False
40-
41-
To suppress this warning, use the :mod:`warnings` module:
42-
43-
.. code-block:: python
44-
45-
import warnings
46-
47-
with warnings.catch_warnings():
48-
# ignore DeprecationWarning on sys.abiflags change on Windows
49-
warnings.simplefilter('ignore', DeprecationWarning)
50-
abiflags = getattr(sys, 'abiflags', '')
51-
52-
Due to historical reasons, :data:`sys.abiflags` is not covered by
53-
:pep:`3149` on Windows. Now we have multiple builds, such as the
54-
:term:`free-threaded <free threading>` build, that provide different ABIs.
55-
:data:`sys.abiflags` is now required under many circumstances to determine
56-
the ABI of the Python interpreter.
57-
58-
The :data:`sys.abiflags` member will be set to a meaningful value on
59-
Windows in Python 3.16. This means the :data:`sys.abiflags` member will
60-
always be available on all platforms starting from Python 3.16.
61-
62-
The following table shows how to migrate from the old code to the new code
63-
without changing the behavior:
64-
65-
+---------------------------------------+---------------------------------------------------------------------+
66-
| Code prior to Python 3.14 | Code prior to Python 3.16 with the same behavior |
67-
+=======================================+=====================================================================+
68-
| ``sys.abiflags`` | ``sys.abiflags`` |
69-
+---------------------------------------+---------------------------------------------------------------------+
70-
| ``getattr(sys, 'abiflags', default)`` | ``sys.abiflags if not sys.platform.startswith('win') else default`` |
71-
+---------------------------------------+---------------------------------------------------------------------+
72-
| ``hasattr(sys, 'abiflags')`` | ``not sys.platform.startswith('win')`` |
73-
+---------------------------------------+---------------------------------------------------------------------+
28+
A :exc:`DeprecationWarning` will be emitted if the :data:`sys.abiflags`
29+
member is accessed on Windows before Python 3.16. The :data:`sys.abiflags`
30+
member will be set to a meaningful value on Windows in Python 3.16. This
31+
means the :data:`sys.abiflags` member will always be available on all
32+
platforms starting from Python 3.16.
33+
34+
See :ref:`whatsnew314-sys-abiflags-change` in the *What's New* for more
35+
details.
7436

7537

7638
.. function:: addaudithook(hook)

Doc/whatsnew/3.14.rst

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

932+
* Schedule a change for availability of :data:`sys.abiflags` on Windows. A
933+
:exc:`DeprecationWarning` will be emitted if the :data:`sys.abiflags` member
934+
is accessed on Windows before Python 3.16.
935+
936+
.. _whatsnew314-sys-abiflags-change:
937+
938+
sys.abiflags
939+
------------
940+
941+
A :exc:`DeprecationWarning` will be emitted if the :data:`sys.abiflags` member
942+
is accessed on Windows before Python 3.16.
943+
For example:
944+
945+
.. code-block:: python
946+
947+
>>> import sys
948+
>>> getattr(sys, 'abiflags', None) # on Windows
949+
<python-input-1>:1: DeprecationWarning: sys.abiflags will be set to a meaningful value on all platforms ...
950+
>>> hasattr(sys, 'abiflags') # on Windows
951+
<python-input-2>:1: DeprecationWarning: sys.abiflags will be set to a meaningful value on all platforms ...
952+
False
953+
954+
To suppress this warning, use the :mod:`warnings` module:
955+
956+
.. code-block:: python
957+
958+
import warnings
959+
960+
with warnings.catch_warnings():
961+
# ignore DeprecationWarning on sys.abiflags change on Windows
962+
warnings.simplefilter('ignore', DeprecationWarning)
963+
abiflags = getattr(sys, 'abiflags', '')
964+
965+
Due to historical reasons, :data:`sys.abiflags` is not covered by
966+
:pep:`3149` on Windows. Now we have multiple builds, such as the
967+
:term:`free-threaded <free threading>` build, that provide different ABIs.
968+
:data:`sys.abiflags` is now required under many circumstances to determine
969+
the ABI of the Python interpreter.
970+
971+
The :data:`sys.abiflags` member will be set to a meaningful value on
972+
Windows in Python 3.16. This means the :data:`sys.abiflags` member will
973+
always be available on all platforms starting from Python 3.16.
974+
975+
The following table shows how to migrate from the old code to the new code
976+
without changing the behavior:
977+
978+
+---------------------------------------+---------------------------------------------------------------------+
979+
| Code prior to Python 3.14 | Code prior to Python 3.16 with the same behavior |
980+
+=======================================+=====================================================================+
981+
| ``sys.abiflags`` | ``sys.abiflags`` |
982+
+---------------------------------------+---------------------------------------------------------------------+
983+
| ``getattr(sys, 'abiflags', default)`` | ``sys.abiflags if not sys.platform.startswith('win') else default`` |
984+
+---------------------------------------+---------------------------------------------------------------------+
985+
| ``hasattr(sys, 'abiflags')`` | ``not sys.platform.startswith('win')`` |
986+
+---------------------------------------+---------------------------------------------------------------------+
932987

933988
sys.monitoring
934989
--------------

0 commit comments

Comments
 (0)