Skip to content

Commit 422773d

Browse files
committed
Merge branch 'main' into pythongh-126612-uop-pass-values
2 parents e2ba2ec + 26ff32b commit 422773d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+496
-328
lines changed

Doc/c-api/init.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,11 @@ function. You can create and destroy them using the following functions:
17381738
.check_multi_interp_extensions = 1,
17391739
.gil = PyInterpreterConfig_OWN_GIL,
17401740
};
1741-
PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);
1741+
PyThreadState *tstate = NULL;
1742+
PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
1743+
if (PyStatus_Exception(status)) {
1744+
Py_ExitStatusException(status);
1745+
}
17421746
17431747
Note that the config is used only briefly and does not get modified.
17441748
During initialization the config's values are converted into various
@@ -2466,7 +2470,7 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`.
24662470
24672471
{
24682472
PyCriticalSection2 _py_cs2;
2469-
PyCriticalSection_Begin2(&_py_cs2, (PyObject*)(a), (PyObject*)(b))
2473+
PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))
24702474
24712475
In the default build, this macro expands to ``{``.
24722476
@@ -2478,7 +2482,7 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`.
24782482
24792483
In the free-threaded build, this macro expands to::
24802484
2481-
PyCriticalSection_End2(&_py_cs2);
2485+
PyCriticalSection2_End(&_py_cs2);
24822486
}
24832487
24842488
In the default build, this macro expands to ``}``.

Doc/c-api/init_config.rst

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Python Initialization Configuration
77
***********************************
88

9+
.. _pyconfig_api:
10+
911
PyConfig C API
1012
==============
1113

@@ -1592,6 +1594,8 @@ The ``__PYVENV_LAUNCHER__`` environment variable is used to set
15921594
:c:member:`PyConfig.base_executable`.
15931595
15941596
1597+
.. _pyinitconfig_api:
1598+
15951599
PyInitConfig C API
15961600
==================
15971601

Doc/library/argparse.rst

+17-10
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@ are strings::
589589
>>> parser.parse_args(['--action', 'sumn', 1, 2, 3])
590590
tester.py: error: argument --action: invalid choice: 'sumn', maybe you meant 'sum'? (choose from 'sum', 'max')
591591

592+
If you're writing code that needs to be compatible with older Python versions
593+
and want to opportunistically use ``suggest_on_error`` when it's available, you
594+
can set it as an attribute after initializing the parser instead of using the
595+
keyword argument::
596+
597+
>>> parser = argparse.ArgumentParser(description='Process some integers.')
598+
>>> parser.suggest_on_error = True
599+
592600
.. versionadded:: 3.14
593601

594602

@@ -1918,11 +1926,10 @@ Argument groups
19181926
Note that any arguments not in your user-defined groups will end up back
19191927
in the usual "positional arguments" and "optional arguments" sections.
19201928

1921-
.. versionchanged:: 3.11
1922-
Calling :meth:`add_argument_group` on an argument group is deprecated.
1923-
This feature was never supported and does not always work correctly.
1924-
The function exists on the API by accident through inheritance and
1925-
will be removed in the future.
1929+
.. deprecated-removed:: 3.11 3.14
1930+
Calling :meth:`add_argument_group` on an argument group now raises an
1931+
exception. This nesting was never supported, often failed to work
1932+
correctly, and was unintentionally exposed through inheritance.
19261933

19271934
.. deprecated:: 3.14
19281935
Passing prefix_chars_ to :meth:`add_argument_group`
@@ -1985,11 +1992,11 @@ Mutual exclusion
19851992
--foo FOO foo help
19861993
--bar BAR bar help
19871994

1988-
.. versionchanged:: 3.11
1989-
Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group`
1990-
on a mutually exclusive group is deprecated. These features were never
1991-
supported and do not always work correctly. The functions exist on the
1992-
API by accident through inheritance and will be removed in the future.
1995+
.. deprecated-removed:: 3.11 3.14
1996+
Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group`
1997+
on a mutually exclusive group now raises an exception. This nesting was
1998+
never supported, often failed to work correctly, and was unintentionally
1999+
exposed through inheritance.
19932000

19942001

19952002
Parser defaults

Doc/library/importlib.metadata.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Entry points
133133

134134
Details of a collection of installed entry points.
135135

136-
Also provides a ``.groups`` attribute that reports all identifed entry
136+
Also provides a ``.groups`` attribute that reports all identified entry
137137
point groups, and a ``.names`` attribute that reports all identified entry
138138
point names.
139139

Doc/library/multiprocessing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ processes:
291291
of corruption from processes using different ends of the pipe at the same
292292
time.
293293

294-
The :meth:`~Connection.send` method serializes the the object and
294+
The :meth:`~Connection.send` method serializes the object and
295295
:meth:`~Connection.recv` re-creates the object.
296296

297297
Synchronization between processes
@@ -828,7 +828,7 @@ For an example of the usage of queues for interprocess communication see
828828
used for receiving messages and ``conn2`` can only be used for sending
829829
messages.
830830

831-
The :meth:`~multiprocessing.Connection.send` method serializes the the object using
831+
The :meth:`~multiprocessing.Connection.send` method serializes the object using
832832
:mod:`pickle` and the :meth:`~multiprocessing.Connection.recv` re-creates the object.
833833

834834
.. class:: Queue([maxsize])

Doc/library/socket.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ The :mod:`socket` module also offers various network-related services:
979979
These addresses should generally be tried in order until a connection succeeds
980980
(possibly tried in parallel, for example, using a `Happy Eyeballs`_ algorithm).
981981
In these cases, limiting the *type* and/or *proto* can help eliminate
982-
unsuccessful or unusable connecton attempts.
982+
unsuccessful or unusable connection attempts.
983983

984984
Some systems will, however, only return a single address.
985985
(For example, this was reported on Solaris and AIX configurations.)
@@ -1596,8 +1596,6 @@ to sockets.
15961596

15971597
.. method:: socket.ioctl(control, option)
15981598

1599-
:platform: Windows
1600-
16011599
The :meth:`ioctl` method is a limited interface to the WSAIoctl system
16021600
interface. Please refer to the `Win32 documentation
16031601
<https://msdn.microsoft.com/en-us/library/ms741621%28VS.85%29.aspx>`_ for more
@@ -1609,9 +1607,12 @@ to sockets.
16091607
Currently only the following control codes are supported:
16101608
``SIO_RCVALL``, ``SIO_KEEPALIVE_VALS``, and ``SIO_LOOPBACK_FAST_PATH``.
16111609

1610+
.. availability:: Windows
1611+
16121612
.. versionchanged:: 3.6
16131613
``SIO_LOOPBACK_FAST_PATH`` was added.
16141614

1615+
16151616
.. method:: socket.listen([backlog])
16161617

16171618
Enable a server to accept connections. If *backlog* is specified, it must

Doc/library/urllib.request.rst

+31-10
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,42 @@ The :mod:`urllib.request` module defines the following functions:
148148

149149
.. function:: pathname2url(path)
150150

151-
Convert the pathname *path* from the local syntax for a path to the form used in
152-
the path component of a URL. This does not produce a complete URL. The return
153-
value will already be quoted using the :func:`~urllib.parse.quote` function.
151+
Convert the given local path to a ``file:`` URL. This function uses
152+
:func:`~urllib.parse.quote` function to encode the path. For historical
153+
reasons, the return value omits the ``file:`` scheme prefix. This example
154+
shows the function being used on Windows::
155+
156+
>>> from urllib.request import pathname2url
157+
>>> path = 'C:\\Program Files'
158+
>>> 'file:' + pathname2url(path)
159+
'file:///C:/Program%20Files'
160+
161+
.. versionchanged:: 3.14
162+
Paths beginning with a slash are converted to URLs with authority
163+
sections. For example, the path ``/etc/hosts`` is converted to
164+
the URL ``///etc/hosts``.
154165

155166
.. versionchanged:: 3.14
156-
On Windows, ``:`` characters not following a drive letter are quoted. In
157-
previous versions, :exc:`OSError` was raised if a colon character was
158-
found in any position other than the second character.
167+
Windows drive letters are no longer converted to uppercase, and ``:``
168+
characters not following a drive letter no longer cause an
169+
:exc:`OSError` exception to be raised on Windows.
170+
159171

172+
.. function:: url2pathname(url)
160173

161-
.. function:: url2pathname(path)
174+
Convert the given ``file:`` URL to a local path. This function uses
175+
:func:`~urllib.parse.unquote` to decode the URL. For historical reasons,
176+
the given value *must* omit the ``file:`` scheme prefix. This example shows
177+
the function being used on Windows::
178+
179+
>>> from urllib.request import url2pathname
180+
>>> url = 'file:///C:/Program%20Files'
181+
>>> url2pathname(url.removeprefix('file:'))
182+
'C:\\Program Files'
183+
184+
.. versionchanged:: 3.14
185+
Windows drive letters are no longer converted to uppercase.
162186

163-
Convert the path component *path* from a percent-encoded URL to the local syntax for a
164-
path. This does not accept a complete URL. This function uses
165-
:func:`~urllib.parse.unquote` to decode *path*.
166187

167188
.. function:: getproxies()
168189

Doc/tutorial/errors.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ complaint you get while you are still learning Python::
2323
^^^^^
2424
SyntaxError: invalid syntax
2525

26-
The parser repeats the offending line and displays little 'arrow's pointing
26+
The parser repeats the offending line and displays little arrows pointing
2727
at the token in the line where the error was detected. The error may be
2828
caused by the absence of a token *before* the indicated token. In the
2929
example, the error is detected at the function :func:`print`, since a colon

Doc/whatsnew/3.11.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ Replaced opcodes
16701670
| | | for each direction |
16711671
| | | |
16721672
+------------------------------------+------------------------------------+-----------------------------------------+
1673-
| | :opcode:`!SETUP_WITH` | :opcode:`BEFORE_WITH` | :keyword:`with` block setup |
1673+
| | :opcode:`!SETUP_WITH` | :opcode:`!BEFORE_WITH` | :keyword:`with` block setup |
16741674
| | :opcode:`!SETUP_ASYNC_WITH` | | |
16751675
+------------------------------------+------------------------------------+-----------------------------------------+
16761676

Doc/whatsnew/3.14.rst

+44
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Summary -- release highlights
6565
6666
.. PEP-sized items next.
6767
68+
* :ref:`PEP 649: deferred evaluation of annotations <whatsnew314-pep649>`
69+
* :ref:`PEP 741: Python Configuration C API <whatsnew314-pep741>`
6870

6971

7072
New features
@@ -172,6 +174,40 @@ Improved error messages
172174
ValueError: too many values to unpack (expected 3, got 4)
173175
174176
177+
.. _whatsnew314-pep741:
178+
179+
PEP 741: Python Configuration C API
180+
-----------------------------------
181+
182+
Add a :ref:`PyInitConfig C API <pyinitconfig_api>` to configure the Python
183+
initialization without relying on C structures and the ability to make
184+
ABI-compatible changes in the future.
185+
186+
Complete the :pep:`587` :ref:`PyConfig C API <pyconfig_api>` by adding
187+
:c:func:`PyInitConfig_AddModule` which can be used to add a built-in extension
188+
module; feature previously referred to as the “inittab”.
189+
190+
Add :c:func:`PyConfig_Get` and :c:func:`PyConfig_Set` functions to get and set
191+
the current runtime configuration.
192+
193+
PEP 587 “Python Initialization Configuration” unified all the ways to configure
194+
the Python initialization. This PEP unifies also the configuration of the
195+
Python preinitialization and the Python initialization in a single API.
196+
Moreover, this PEP only provides a single choice to embed Python, instead of
197+
having two “Python” and “Isolated” choices (PEP 587), to simplify the API
198+
further.
199+
200+
The lower level PEP 587 PyConfig API remains available for use cases with an
201+
intentionally higher level of coupling to CPython implementation details (such
202+
as emulating the full functionality of CPython’s CLI, including its
203+
configuration mechanisms).
204+
205+
(Contributed by Victor Stinner in :gh:`107954`.)
206+
207+
.. seealso::
208+
:pep:`741`.
209+
210+
175211
Other language changes
176212
======================
177213

@@ -641,6 +677,14 @@ argparse
641677
of :class:`!argparse.BooleanOptionalAction`.
642678
They were deprecated since 3.12.
643679

680+
* Calling :meth:`~argparse.ArgumentParser.add_argument_group` on an argument
681+
group, and calling :meth:`~argparse.ArgumentParser.add_argument_group` or
682+
:meth:`~argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually
683+
exclusive group now raise exceptions. This nesting was never supported,
684+
often failed to work correctly, and was unintentionally exposed through
685+
inheritance. This functionality has been deprecated since Python 3.11.
686+
(Contributed by Savannah Ostrowski in :gh:`127186`.)
687+
644688
ast
645689
---
646690

Doc/whatsnew/3.4.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ Other Improvements
19791979
now works correctly (previously it silently returned the first python
19801980
module in the file). (Contributed by Václav Šmilauer in :issue:`16421`.)
19811981

1982-
* A new opcode, :opcode:`LOAD_CLASSDEREF`, has been added to fix a bug in the
1982+
* A new opcode, :opcode:`!LOAD_CLASSDEREF`, has been added to fix a bug in the
19831983
loading of free variables in class bodies that could be triggered by certain
19841984
uses of :ref:`__prepare__ <prepare>`. (Contributed by Benjamin Peterson in
19851985
:issue:`17853`.)

Doc/whatsnew/3.6.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -2366,27 +2366,27 @@ There have been several major changes to the :term:`bytecode` in Python 3.6.
23662366
(Contributed by Demur Rumed with input and reviews from
23672367
Serhiy Storchaka and Victor Stinner in :issue:`26647` and :issue:`28050`.)
23682368

2369-
* The new :opcode:`FORMAT_VALUE` and :opcode:`BUILD_STRING` opcodes as part
2369+
* The new :opcode:`!FORMAT_VALUE` and :opcode:`BUILD_STRING` opcodes as part
23702370
of the :ref:`formatted string literal <whatsnew36-pep498>` implementation.
23712371
(Contributed by Eric Smith in :issue:`25483` and
23722372
Serhiy Storchaka in :issue:`27078`.)
23732373

2374-
* The new :opcode:`BUILD_CONST_KEY_MAP` opcode to optimize the creation
2374+
* The new :opcode:`!BUILD_CONST_KEY_MAP` opcode to optimize the creation
23752375
of dictionaries with constant keys.
23762376
(Contributed by Serhiy Storchaka in :issue:`27140`.)
23772377

23782378
* The function call opcodes have been heavily reworked for better performance
23792379
and simpler implementation.
2380-
The :opcode:`MAKE_FUNCTION`, :opcode:`CALL_FUNCTION`,
2381-
:opcode:`CALL_FUNCTION_KW` and :opcode:`BUILD_MAP_UNPACK_WITH_CALL` opcodes
2380+
The :opcode:`MAKE_FUNCTION`, :opcode:`!CALL_FUNCTION`,
2381+
:opcode:`!CALL_FUNCTION_KW` and :opcode:`!BUILD_MAP_UNPACK_WITH_CALL` opcodes
23822382
have been modified, the new :opcode:`CALL_FUNCTION_EX` and
2383-
:opcode:`BUILD_TUPLE_UNPACK_WITH_CALL` have been added, and
2383+
:opcode:`!BUILD_TUPLE_UNPACK_WITH_CALL` have been added, and
23842384
``CALL_FUNCTION_VAR``, ``CALL_FUNCTION_VAR_KW`` and ``MAKE_CLOSURE`` opcodes
23852385
have been removed.
23862386
(Contributed by Demur Rumed in :issue:`27095`, and Serhiy Storchaka in
23872387
:issue:`27213`, :issue:`28257`.)
23882388

2389-
* The new :opcode:`SETUP_ANNOTATIONS` and :opcode:`STORE_ANNOTATION` opcodes
2389+
* The new :opcode:`SETUP_ANNOTATIONS` and :opcode:`!STORE_ANNOTATION` opcodes
23902390
have been added to support the new :term:`variable annotation` syntax.
23912391
(Contributed by Ivan Levkivskyi in :issue:`27985`.)
23922392

Doc/whatsnew/3.7.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2476,10 +2476,10 @@ avoiding possible problems use new functions :c:func:`PySlice_Unpack` and
24762476
CPython bytecode changes
24772477
------------------------
24782478

2479-
There are two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`CALL_METHOD`.
2479+
There are two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`!CALL_METHOD`.
24802480
(Contributed by Yury Selivanov and INADA Naoki in :issue:`26110`.)
24812481

2482-
The :opcode:`STORE_ANNOTATION` opcode has been removed.
2482+
The :opcode:`!STORE_ANNOTATION` opcode has been removed.
24832483
(Contributed by Mark Shannon in :issue:`32550`.)
24842484

24852485

Doc/whatsnew/3.8.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -2152,11 +2152,11 @@ CPython bytecode changes
21522152
cleaning-up code for :keyword:`break`, :keyword:`continue` and
21532153
:keyword:`return`.
21542154

2155-
Removed opcodes :opcode:`BREAK_LOOP`, :opcode:`CONTINUE_LOOP`,
2156-
:opcode:`SETUP_LOOP` and :opcode:`SETUP_EXCEPT`. Added new opcodes
2157-
:opcode:`ROT_FOUR`, :opcode:`BEGIN_FINALLY`, :opcode:`CALL_FINALLY` and
2158-
:opcode:`POP_FINALLY`. Changed the behavior of :opcode:`END_FINALLY`
2159-
and :opcode:`WITH_CLEANUP_START`.
2155+
Removed opcodes :opcode:`!BREAK_LOOP`, :opcode:`!CONTINUE_LOOP`,
2156+
:opcode:`!SETUP_LOOP` and :opcode:`!SETUP_EXCEPT`. Added new opcodes
2157+
:opcode:`!ROT_FOUR`, :opcode:`!BEGIN_FINALLY`, :opcode:`!CALL_FINALLY` and
2158+
:opcode:`!POP_FINALLY`. Changed the behavior of :opcode:`!END_FINALLY`
2159+
and :opcode:`!WITH_CLEANUP_START`.
21602160

21612161
(Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka in
21622162
:issue:`17611`.)

Doc/whatsnew/3.9.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ Changes in the C API
12031203
CPython bytecode changes
12041204
------------------------
12051205

1206-
* The :opcode:`LOAD_ASSERTION_ERROR` opcode was added for handling the
1206+
* The :opcode:`!LOAD_ASSERTION_ERROR` opcode was added for handling the
12071207
:keyword:`assert` statement. Previously, the assert statement would not work
12081208
correctly if the :exc:`AssertionError` exception was being shadowed.
12091209
(Contributed by Zackery Spytz in :issue:`34880`.)

0 commit comments

Comments
 (0)