Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-126612-uop-pass-values
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Nov 25, 2024
2 parents e2ba2ec + 26ff32b commit 422773d
Show file tree
Hide file tree
Showing 49 changed files with 496 additions and 328 deletions.
10 changes: 7 additions & 3 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,11 @@ function. You can create and destroy them using the following functions:
.check_multi_interp_extensions = 1,
.gil = PyInterpreterConfig_OWN_GIL,
};
PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);
PyThreadState *tstate = NULL;
PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
}
Note that the config is used only briefly and does not get modified.
During initialization the config's values are converted into various
Expand Down Expand Up @@ -2466,7 +2470,7 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`.
{
PyCriticalSection2 _py_cs2;
PyCriticalSection_Begin2(&_py_cs2, (PyObject*)(a), (PyObject*)(b))
PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))
In the default build, this macro expands to ``{``.
Expand All @@ -2478,7 +2482,7 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`.
In the free-threaded build, this macro expands to::
PyCriticalSection_End2(&_py_cs2);
PyCriticalSection2_End(&_py_cs2);
}
In the default build, this macro expands to ``}``.
Expand Down
4 changes: 4 additions & 0 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Python Initialization Configuration
***********************************

.. _pyconfig_api:

PyConfig C API
==============

Expand Down Expand Up @@ -1592,6 +1594,8 @@ The ``__PYVENV_LAUNCHER__`` environment variable is used to set
:c:member:`PyConfig.base_executable`.
.. _pyinitconfig_api:
PyInitConfig C API
==================
Expand Down
27 changes: 17 additions & 10 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,14 @@ are strings::
>>> parser.parse_args(['--action', 'sumn', 1, 2, 3])
tester.py: error: argument --action: invalid choice: 'sumn', maybe you meant 'sum'? (choose from 'sum', 'max')

If you're writing code that needs to be compatible with older Python versions
and want to opportunistically use ``suggest_on_error`` when it's available, you
can set it as an attribute after initializing the parser instead of using the
keyword argument::

>>> parser = argparse.ArgumentParser(description='Process some integers.')
>>> parser.suggest_on_error = True

.. versionadded:: 3.14


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

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

.. deprecated:: 3.14
Passing prefix_chars_ to :meth:`add_argument_group`
Expand Down Expand Up @@ -1985,11 +1992,11 @@ Mutual exclusion
--foo FOO foo help
--bar BAR bar help

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


Parser defaults
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/importlib.metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Entry points

Details of a collection of installed entry points.

Also provides a ``.groups`` attribute that reports all identifed entry
Also provides a ``.groups`` attribute that reports all identified entry
point groups, and a ``.names`` attribute that reports all identified entry
point names.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ processes:
of corruption from processes using different ends of the pipe at the same
time.

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

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

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

.. class:: Queue([maxsize])
Expand Down
7 changes: 4 additions & 3 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ The :mod:`socket` module also offers various network-related services:
These addresses should generally be tried in order until a connection succeeds
(possibly tried in parallel, for example, using a `Happy Eyeballs`_ algorithm).
In these cases, limiting the *type* and/or *proto* can help eliminate
unsuccessful or unusable connecton attempts.
unsuccessful or unusable connection attempts.

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

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

:platform: Windows

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

.. availability:: Windows

.. versionchanged:: 3.6
``SIO_LOOPBACK_FAST_PATH`` was added.


.. method:: socket.listen([backlog])

Enable a server to accept connections. If *backlog* is specified, it must
Expand Down
41 changes: 31 additions & 10 deletions Doc/library/urllib.request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,42 @@ The :mod:`urllib.request` module defines the following functions:

.. function:: pathname2url(path)

Convert the pathname *path* from the local syntax for a path to the form used in
the path component of a URL. This does not produce a complete URL. The return
value will already be quoted using the :func:`~urllib.parse.quote` function.
Convert the given local path to a ``file:`` URL. This function uses
:func:`~urllib.parse.quote` function to encode the path. For historical
reasons, the return value omits the ``file:`` scheme prefix. This example
shows the function being used on Windows::

>>> from urllib.request import pathname2url
>>> path = 'C:\\Program Files'
>>> 'file:' + pathname2url(path)
'file:///C:/Program%20Files'

.. versionchanged:: 3.14
Paths beginning with a slash are converted to URLs with authority
sections. For example, the path ``/etc/hosts`` is converted to
the URL ``///etc/hosts``.

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


.. function:: url2pathname(url)

.. function:: url2pathname(path)
Convert the given ``file:`` URL to a local path. This function uses
:func:`~urllib.parse.unquote` to decode the URL. For historical reasons,
the given value *must* omit the ``file:`` scheme prefix. This example shows
the function being used on Windows::

>>> from urllib.request import url2pathname
>>> url = 'file:///C:/Program%20Files'
>>> url2pathname(url.removeprefix('file:'))
'C:\\Program Files'

.. versionchanged:: 3.14
Windows drive letters are no longer converted to uppercase.

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

.. function:: getproxies()

Expand Down
2 changes: 1 addition & 1 deletion Doc/tutorial/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ complaint you get while you are still learning Python::
^^^^^
SyntaxError: invalid syntax

The parser repeats the offending line and displays little 'arrow's pointing
The parser repeats the offending line and displays little arrows pointing
at the token in the line where the error was detected. The error may be
caused by the absence of a token *before* the indicated token. In the
example, the error is detected at the function :func:`print`, since a colon
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ Replaced opcodes
| | | for each direction |
| | | |
+------------------------------------+------------------------------------+-----------------------------------------+
| | :opcode:`!SETUP_WITH` | :opcode:`BEFORE_WITH` | :keyword:`with` block setup |
| | :opcode:`!SETUP_WITH` | :opcode:`!BEFORE_WITH` | :keyword:`with` block setup |
| | :opcode:`!SETUP_ASYNC_WITH` | | |
+------------------------------------+------------------------------------+-----------------------------------------+

Expand Down
44 changes: 44 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Summary -- release highlights
.. PEP-sized items next.
* :ref:`PEP 649: deferred evaluation of annotations <whatsnew314-pep649>`
* :ref:`PEP 741: Python Configuration C API <whatsnew314-pep741>`


New features
Expand Down Expand Up @@ -172,6 +174,40 @@ Improved error messages
ValueError: too many values to unpack (expected 3, got 4)
.. _whatsnew314-pep741:

PEP 741: Python Configuration C API
-----------------------------------

Add a :ref:`PyInitConfig C API <pyinitconfig_api>` to configure the Python
initialization without relying on C structures and the ability to make
ABI-compatible changes in the future.

Complete the :pep:`587` :ref:`PyConfig C API <pyconfig_api>` by adding
:c:func:`PyInitConfig_AddModule` which can be used to add a built-in extension
module; feature previously referred to as the “inittab”.

Add :c:func:`PyConfig_Get` and :c:func:`PyConfig_Set` functions to get and set
the current runtime configuration.

PEP 587 “Python Initialization Configuration” unified all the ways to configure
the Python initialization. This PEP unifies also the configuration of the
Python preinitialization and the Python initialization in a single API.
Moreover, this PEP only provides a single choice to embed Python, instead of
having two “Python” and “Isolated” choices (PEP 587), to simplify the API
further.

The lower level PEP 587 PyConfig API remains available for use cases with an
intentionally higher level of coupling to CPython implementation details (such
as emulating the full functionality of CPython’s CLI, including its
configuration mechanisms).

(Contributed by Victor Stinner in :gh:`107954`.)

.. seealso::
:pep:`741`.


Other language changes
======================

Expand Down Expand Up @@ -641,6 +677,14 @@ argparse
of :class:`!argparse.BooleanOptionalAction`.
They were deprecated since 3.12.

* Calling :meth:`~argparse.ArgumentParser.add_argument_group` on an argument
group, and calling :meth:`~argparse.ArgumentParser.add_argument_group` or
:meth:`~argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually
exclusive group now raise exceptions. This nesting was never supported,
often failed to work correctly, and was unintentionally exposed through
inheritance. This functionality has been deprecated since Python 3.11.
(Contributed by Savannah Ostrowski in :gh:`127186`.)

ast
---

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ Other Improvements
now works correctly (previously it silently returned the first python
module in the file). (Contributed by Václav Šmilauer in :issue:`16421`.)

* A new opcode, :opcode:`LOAD_CLASSDEREF`, has been added to fix a bug in the
* A new opcode, :opcode:`!LOAD_CLASSDEREF`, has been added to fix a bug in the
loading of free variables in class bodies that could be triggered by certain
uses of :ref:`__prepare__ <prepare>`. (Contributed by Benjamin Peterson in
:issue:`17853`.)
Expand Down
12 changes: 6 additions & 6 deletions Doc/whatsnew/3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2366,27 +2366,27 @@ There have been several major changes to the :term:`bytecode` in Python 3.6.
(Contributed by Demur Rumed with input and reviews from
Serhiy Storchaka and Victor Stinner in :issue:`26647` and :issue:`28050`.)

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

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

* The function call opcodes have been heavily reworked for better performance
and simpler implementation.
The :opcode:`MAKE_FUNCTION`, :opcode:`CALL_FUNCTION`,
:opcode:`CALL_FUNCTION_KW` and :opcode:`BUILD_MAP_UNPACK_WITH_CALL` opcodes
The :opcode:`MAKE_FUNCTION`, :opcode:`!CALL_FUNCTION`,
:opcode:`!CALL_FUNCTION_KW` and :opcode:`!BUILD_MAP_UNPACK_WITH_CALL` opcodes
have been modified, the new :opcode:`CALL_FUNCTION_EX` and
:opcode:`BUILD_TUPLE_UNPACK_WITH_CALL` have been added, and
:opcode:`!BUILD_TUPLE_UNPACK_WITH_CALL` have been added, and
``CALL_FUNCTION_VAR``, ``CALL_FUNCTION_VAR_KW`` and ``MAKE_CLOSURE`` opcodes
have been removed.
(Contributed by Demur Rumed in :issue:`27095`, and Serhiy Storchaka in
:issue:`27213`, :issue:`28257`.)

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

Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2476,10 +2476,10 @@ avoiding possible problems use new functions :c:func:`PySlice_Unpack` and
CPython bytecode changes
------------------------

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

The :opcode:`STORE_ANNOTATION` opcode has been removed.
The :opcode:`!STORE_ANNOTATION` opcode has been removed.
(Contributed by Mark Shannon in :issue:`32550`.)


Expand Down
10 changes: 5 additions & 5 deletions Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2152,11 +2152,11 @@ CPython bytecode changes
cleaning-up code for :keyword:`break`, :keyword:`continue` and
:keyword:`return`.

Removed opcodes :opcode:`BREAK_LOOP`, :opcode:`CONTINUE_LOOP`,
:opcode:`SETUP_LOOP` and :opcode:`SETUP_EXCEPT`. Added new opcodes
:opcode:`ROT_FOUR`, :opcode:`BEGIN_FINALLY`, :opcode:`CALL_FINALLY` and
:opcode:`POP_FINALLY`. Changed the behavior of :opcode:`END_FINALLY`
and :opcode:`WITH_CLEANUP_START`.
Removed opcodes :opcode:`!BREAK_LOOP`, :opcode:`!CONTINUE_LOOP`,
:opcode:`!SETUP_LOOP` and :opcode:`!SETUP_EXCEPT`. Added new opcodes
:opcode:`!ROT_FOUR`, :opcode:`!BEGIN_FINALLY`, :opcode:`!CALL_FINALLY` and
:opcode:`!POP_FINALLY`. Changed the behavior of :opcode:`!END_FINALLY`
and :opcode:`!WITH_CLEANUP_START`.

(Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka in
:issue:`17611`.)
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ Changes in the C API
CPython bytecode changes
------------------------

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

0 comments on commit 422773d

Please sign in to comment.