aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/code.rst65
-rw-r--r--Doc/c-api/structures.rst75
-rw-r--r--Doc/c-api/typeobj.rst11
-rw-r--r--Doc/c-api/veryhigh.rst8
-rw-r--r--Doc/conf.py19
-rw-r--r--Doc/glossary.rst13
-rw-r--r--Doc/howto/logging-cookbook.rst98
-rw-r--r--Doc/library/__future__.rst78
-rw-r--r--Doc/library/argparse.rst37
-rw-r--r--Doc/library/codecs.rst74
-rw-r--r--Doc/library/email.compat32-message.rst18
-rw-r--r--Doc/library/exceptions.rst30
-rw-r--r--Doc/library/multiprocessing.rst12
-rw-r--r--Doc/library/os.path.rst7
-rw-r--r--Doc/library/pyexpat.rst7
-rw-r--r--Doc/library/random.rst5
-rw-r--r--Doc/library/security_warnings.rst2
-rw-r--r--Doc/library/sqlite3.rst2
-rw-r--r--Doc/library/sys.rst2
-rw-r--r--Doc/library/unittest.rst2
-rw-r--r--Doc/library/xml.dom.minidom.rst7
-rw-r--r--Doc/library/xml.dom.pulldom.rst7
-rw-r--r--Doc/library/xml.etree.elementtree.rst7
-rw-r--r--Doc/library/xml.rst76
-rw-r--r--Doc/library/xml.sax.rst7
-rw-r--r--Doc/library/xmlrpc.client.rst4
-rw-r--r--Doc/library/xmlrpc.server.rst4
-rw-r--r--Doc/tools/.nitignore4
-rw-r--r--Doc/using/configure.rst7
-rw-r--r--Doc/whatsnew/3.11.rst2
-rw-r--r--Doc/whatsnew/3.9.rst8
31 files changed, 486 insertions, 212 deletions
diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst
index 42594f063b0..717b0da8f87 100644
--- a/Doc/c-api/code.rst
+++ b/Doc/c-api/code.rst
@@ -211,6 +211,71 @@ bound into a function.
.. versionadded:: 3.12
+.. _c_codeobject_flags:
+
+Code Object Flags
+-----------------
+
+Code objects contain a bit-field of flags, which can be retrieved as the
+:attr:`~codeobject.co_flags` Python attribute (for example using
+:c:func:`PyObject_GetAttrString`), and set using a *flags* argument to
+:c:func:`PyUnstable_Code_New` and similar functions.
+
+Flags whose names start with ``CO_FUTURE_`` correspond to features normally
+selectable by :ref:`future statements <future>`. These flags can be used in
+:c:member:`PyCompilerFlags.cf_flags`.
+Note that many ``CO_FUTURE_`` flags are mandatory in current versions of
+Python, and setting them has no effect.
+
+The following flags are available.
+For their meaning, see the linked documentation of their Python equivalents.
+
+
+.. list-table::
+ :widths: auto
+ :header-rows: 1
+
+ * * Flag
+ * Meaning
+ * * .. c:macro:: CO_OPTIMIZED
+ * :py:data:`inspect.CO_OPTIMIZED`
+ * * .. c:macro:: CO_NEWLOCALS
+ * :py:data:`inspect.CO_NEWLOCALS`
+ * * .. c:macro:: CO_VARARGS
+ * :py:data:`inspect.CO_VARARGS`
+ * * .. c:macro:: CO_VARKEYWORDS
+ * :py:data:`inspect.CO_VARKEYWORDS`
+ * * .. c:macro:: CO_NESTED
+ * :py:data:`inspect.CO_NESTED`
+ * * .. c:macro:: CO_GENERATOR
+ * :py:data:`inspect.CO_GENERATOR`
+ * * .. c:macro:: CO_COROUTINE
+ * :py:data:`inspect.CO_COROUTINE`
+ * * .. c:macro:: CO_ITERABLE_COROUTINE
+ * :py:data:`inspect.CO_ITERABLE_COROUTINE`
+ * * .. c:macro:: CO_ASYNC_GENERATOR
+ * :py:data:`inspect.CO_ASYNC_GENERATOR`
+ * * .. c:macro:: CO_HAS_DOCSTRING
+ * :py:data:`inspect.CO_HAS_DOCSTRING`
+ * * .. c:macro:: CO_METHOD
+ * :py:data:`inspect.CO_METHOD`
+
+ * * .. c:macro:: CO_FUTURE_DIVISION
+ * no effect (:py:data:`__future__.division`)
+ * * .. c:macro:: CO_FUTURE_ABSOLUTE_IMPORT
+ * no effect (:py:data:`__future__.absolute_import`)
+ * * .. c:macro:: CO_FUTURE_WITH_STATEMENT
+ * no effect (:py:data:`__future__.with_statement`)
+ * * .. c:macro:: CO_FUTURE_PRINT_FUNCTION
+ * no effect (:py:data:`__future__.print_function`)
+ * * .. c:macro:: CO_FUTURE_UNICODE_LITERALS
+ * no effect (:py:data:`__future__.unicode_literals`)
+ * * .. c:macro:: CO_FUTURE_GENERATOR_STOP
+ * no effect (:py:data:`__future__.generator_stop`)
+ * * .. c:macro:: CO_FUTURE_ANNOTATIONS
+ * :py:data:`__future__.annotations`
+
+
Extra information
-----------------
diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst
index 987bc167c68..58dd915e04f 100644
--- a/Doc/c-api/structures.rst
+++ b/Doc/c-api/structures.rst
@@ -28,18 +28,52 @@ under :ref:`reference counting <countingrefs>`.
object. In a normal "release" build, it contains only the object's
reference count and a pointer to the corresponding type object.
Nothing is actually declared to be a :c:type:`PyObject`, but every pointer
- to a Python object can be cast to a :c:expr:`PyObject*`. Access to the
- members must be done by using the macros :c:macro:`Py_REFCNT` and
- :c:macro:`Py_TYPE`.
+ to a Python object can be cast to a :c:expr:`PyObject*`.
+
+ The members must not be accessed directly; instead use macros such as
+ :c:macro:`Py_REFCNT` and :c:macro:`Py_TYPE`.
+
+ .. c:member:: Py_ssize_t ob_refcnt
+
+ The object's reference count, as returned by :c:macro:`Py_REFCNT`.
+ Do not use this field directly; instead use functions and macros such as
+ :c:macro:`!Py_REFCNT`, :c:func:`Py_INCREF` and :c:func:`Py_DecRef`.
+
+ The field type may be different from ``Py_ssize_t``, depending on
+ build configuration and platform.
+
+ .. c:member:: PyTypeObject* ob_type
+
+ The object's type.
+ Do not use this field directly; use :c:macro:`Py_TYPE` and
+ :c:func:`Py_SET_TYPE` instead.
.. c:type:: PyVarObject
- This is an extension of :c:type:`PyObject` that adds the :c:member:`~PyVarObject.ob_size`
- field. This is only used for objects that have some notion of *length*.
- This type does not often appear in the Python/C API.
- Access to the members must be done by using the macros
- :c:macro:`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`.
+ An extension of :c:type:`PyObject` that adds the
+ :c:member:`~PyVarObject.ob_size` field.
+ This is intended for objects that have some notion of *length*.
+
+ As with :c:type:`!PyObject`, the members must not be accessed directly;
+ instead use macros such as :c:macro:`Py_SIZE`, :c:macro:`Py_REFCNT` and
+ :c:macro:`Py_TYPE`.
+
+ .. c:member:: Py_ssize_t ob_size
+
+ A size field, whose contents should be considered an object's internal
+ implementation detail.
+
+ Do not use this field directly; use :c:macro:`Py_SIZE` instead.
+
+ Object creation functions such as :c:func:`PyObject_NewVar` will
+ generally set this field to the requested size (number of items).
+ After creation, arbitrary values can be stored in :c:member:`!ob_size`
+ using :c:macro:`Py_SET_SIZE`.
+
+ To get an object's publicly exposed length, as returned by
+ the Python function :py:func:`len`, use :c:func:`PyObject_Length`
+ instead.
.. c:macro:: PyObject_HEAD
@@ -103,9 +137,8 @@ under :ref:`reference counting <countingrefs>`.
Get the type of the Python object *o*.
- Return a :term:`borrowed reference`.
-
- Use the :c:func:`Py_SET_TYPE` function to set an object type.
+ The returned reference is :term:`borrowed <borrowed reference>` from *o*.
+ Do not release it with :c:func:`Py_DECREF` or similar.
.. versionchanged:: 3.11
:c:func:`Py_TYPE()` is changed to an inline static function.
@@ -122,16 +155,26 @@ under :ref:`reference counting <countingrefs>`.
.. c:function:: void Py_SET_TYPE(PyObject *o, PyTypeObject *type)
- Set the object *o* type to *type*.
+ Set the type of object *o* to *type*, without any checking or reference
+ counting.
+
+ This is a very low-level operation.
+ Consider instead setting the Python attribute :attr:`~object.__class__`
+ using :c:func:`PyObject_SetAttrString` or similar.
+
+ Note that assigning an incompatible type can lead to undefined behavior.
+
+ If *type* is a :ref:`heap type <heap-types>`, the caller must create a
+ new reference to it.
+ Similarly, if the old type of *o* is a heap type, the caller must release
+ a reference to that type.
.. versionadded:: 3.9
.. c:function:: Py_ssize_t Py_SIZE(PyVarObject *o)
- Get the size of the Python object *o*.
-
- Use the :c:func:`Py_SET_SIZE` function to set an object size.
+ Get the :c:member:`~PyVarObject.ob_size` field of *o*.
.. versionchanged:: 3.11
:c:func:`Py_SIZE()` is changed to an inline static function.
@@ -140,7 +183,7 @@ under :ref:`reference counting <countingrefs>`.
.. c:function:: void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size)
- Set the object *o* size to *size*.
+ Set the :c:member:`~PyVarObject.ob_size` field of *o* to *size*.
.. versionadded:: 3.9
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index af2bead3bb5..060d6f60174 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -492,9 +492,9 @@ metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that it
type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
-.. c:member:: Py_ssize_t PyObject.ob_refcnt
+:c:member:`PyObject.ob_refcnt`
- This is the type object's reference count, initialized to ``1`` by the
+ The type object's reference count is initialized to ``1`` by the
``PyObject_HEAD_INIT`` macro. Note that for :ref:`statically allocated type
objects <static-types>`, the type's instances (objects whose :c:member:`~PyObject.ob_type`
points back to the type) do *not* count as references. But for
@@ -506,7 +506,7 @@ type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
This field is not inherited by subtypes.
-.. c:member:: PyTypeObject* PyObject.ob_type
+:c:member:`PyObject.ob_type`
This is the type's type, in other words its metatype. It is initialized by the
argument to the ``PyObject_HEAD_INIT`` macro, and its value should normally be
@@ -532,14 +532,13 @@ type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
PyVarObject Slots
-----------------
-.. c:member:: Py_ssize_t PyVarObject.ob_size
+:c:member:`PyVarObject.ob_size`
For :ref:`statically allocated type objects <static-types>`, this should be
initialized to zero. For :ref:`dynamically allocated type objects
<heap-types>`, this field has a special internal meaning.
- This field should be accessed using the :c:func:`Py_SIZE()` and
- :c:func:`Py_SET_SIZE()` macros.
+ This field should be accessed using the :c:func:`Py_SIZE()` macro.
**Inheritance:**
diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst
index 1ef4181d52e..fb07fec7eff 100644
--- a/Doc/c-api/veryhigh.rst
+++ b/Doc/c-api/veryhigh.rst
@@ -361,7 +361,7 @@ the same library that the Python runtime is using.
:py:mod:`!ast` Python module, which exports these constants under
the same names.
- .. c:var:: int CO_FUTURE_DIVISION
-
- This bit can be set in *flags* to cause division operator ``/`` to be
- interpreted as "true division" according to :pep:`238`.
+ The "``PyCF``" flags above can be combined with "``CO_FUTURE``" flags such
+ as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally
+ selectable using :ref:`future statements <future>`.
+ See :ref:`c_codeobject_flags` for a complete list.
diff --git a/Doc/conf.py b/Doc/conf.py
index 161c2986441..8b2a8f20fcc 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -635,13 +635,14 @@ ogp_social_cards = { # Used when matplotlib is installed
'image': '_static/og-image.png',
'line_color': '#3776ab',
}
-ogp_custom_meta_tags = [
- '<meta name="theme-color" content="#3776ab">',
-]
-if 'create-social-cards' not in tags: # noqa: F821
- # Define a static preview image when not creating social cards
- ogp_image = '_static/og-image.png'
- ogp_custom_meta_tags += [
- '<meta property="og:image:width" content="200">',
- '<meta property="og:image:height" content="200">',
+if 'builder_html' in tags: # noqa: F821
+ ogp_custom_meta_tags = [
+ '<meta name="theme-color" content="#3776ab">',
]
+ if 'create-social-cards' not in tags: # noqa: F821
+ # Define a static preview image when not creating social cards
+ ogp_image = '_static/og-image.png'
+ ogp_custom_meta_tags += [
+ '<meta property="og:image:width" content="200">',
+ '<meta property="og:image:height" content="200">',
+ ]
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index c5c7994f126..705b0a9279c 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -1280,6 +1280,16 @@ Glossary
and ending with double underscores. Special methods are documented in
:ref:`specialnames`.
+ standard library
+ The collection of :term:`packages <package>`, :term:`modules <module>`
+ and :term:`extension modules <extension module>` distributed as a part
+ of the official Python interpreter package. The exact membership of the
+ collection may vary based on platform, available system libraries, or
+ other criteria. Documentation can be found at :ref:`library-index`.
+
+ See also :data:`sys.stdlib_module_names` for a list of all possible
+ standard library module names.
+
statement
A statement is part of a suite (a "block" of code). A statement is either
an :term:`expression` or one of several constructs with a keyword, such
@@ -1290,6 +1300,9 @@ Glossary
issues such as incorrect types. See also :term:`type hints <type hint>`
and the :mod:`typing` module.
+ stdlib
+ An abbreviation of :term:`standard library`.
+
strong reference
In Python's C API, a strong reference is a reference to an object
which is owned by the code holding the reference. The strong
diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst
index 7d64a02358a..52537a91df5 100644
--- a/Doc/howto/logging-cookbook.rst
+++ b/Doc/howto/logging-cookbook.rst
@@ -4078,6 +4078,104 @@ lines. With this approach, you get better output:
WARNING:demo: 1/0
WARNING:demo:ZeroDivisionError: division by zero
+How to uniformly handle newlines in logging output
+--------------------------------------------------
+
+Usually, messages that are logged (say to console or file) consist of a single
+line of text. However, sometimes there is a need to handle messages with
+multiple lines - whether because a logging format string contains newlines, or
+logged data contains newlines. If you want to handle such messages uniformly, so
+that each line in the logged message appears uniformly formatted as if it was
+logged separately, you can do this using a handler mixin, as in the following
+snippet:
+
+.. code-block:: python
+
+ # Assume this is in a module mymixins.py
+ import copy
+
+ class MultilineMixin:
+ def emit(self, record):
+ s = record.getMessage()
+ if '\n' not in s:
+ super().emit(record)
+ else:
+ lines = s.splitlines()
+ rec = copy.copy(record)
+ rec.args = None
+ for line in lines:
+ rec.msg = line
+ super().emit(rec)
+
+You can use the mixin as in the following script:
+
+.. code-block:: python
+
+ import logging
+
+ from mymixins import MultilineMixin
+
+ logger = logging.getLogger(__name__)
+
+ class StreamHandler(MultilineMixin, logging.StreamHandler):
+ pass
+
+ if __name__ == '__main__':
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s',
+ handlers = [StreamHandler()])
+ logger.debug('Single line')
+ logger.debug('Multiple lines:\nfool me once ...')
+ logger.debug('Another single line')
+ logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again')
+
+The script, when run, prints something like:
+
+.. code-block:: text
+
+ 2025-07-02 13:54:47,234 DEBUG Single line
+ 2025-07-02 13:54:47,234 DEBUG Multiple lines:
+ 2025-07-02 13:54:47,234 DEBUG fool me once ...
+ 2025-07-02 13:54:47,234 DEBUG Another single line
+ 2025-07-02 13:54:47,234 DEBUG Multiple lines:
+ 2025-07-02 13:54:47,234 DEBUG fool me ...
+ 2025-07-02 13:54:47,234 DEBUG can't get fooled again
+
+If, on the other hand, you are concerned about `log injection
+<https://owasp.org/www-community/attacks/Log_Injection>`_, you can use a
+formatter which escapes newlines, as per the following example:
+
+.. code-block:: python
+
+ import logging
+
+ logger = logging.getLogger(__name__)
+
+ class EscapingFormatter(logging.Formatter):
+ def format(self, record):
+ s = super().format(record)
+ return s.replace('\n', r'\n')
+
+ if __name__ == '__main__':
+ h = logging.StreamHandler()
+ h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s'))
+ logging.basicConfig(level=logging.DEBUG, handlers = [h])
+ logger.debug('Single line')
+ logger.debug('Multiple lines:\nfool me once ...')
+ logger.debug('Another single line')
+ logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again')
+
+You can, of course, use whatever escaping scheme makes the most sense for you.
+The script, when run, should produce output like this:
+
+.. code-block:: text
+
+ 2025-07-09 06:47:33,783 DEBUG Single line
+ 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me once ...
+ 2025-07-09 06:47:33,783 DEBUG Another single line
+ 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me ...\ncan't get fooled again
+
+Escaping behaviour can't be the stdlib default , as it would break backwards
+compatibility.
.. patterns-to-avoid:
diff --git a/Doc/library/__future__.rst b/Doc/library/__future__.rst
index 4f3b663006f..5d916b30112 100644
--- a/Doc/library/__future__.rst
+++ b/Doc/library/__future__.rst
@@ -37,38 +37,52 @@ No feature description will ever be deleted from :mod:`__future__`. Since its
introduction in Python 2.1 the following features have found their way into the
language using this mechanism:
-+------------------+-------------+--------------+---------------------------------------------+
-| feature | optional in | mandatory in | effect |
-+==================+=============+==============+=============================================+
-| nested_scopes | 2.1.0b1 | 2.2 | :pep:`227`: |
-| | | | *Statically Nested Scopes* |
-+------------------+-------------+--------------+---------------------------------------------+
-| generators | 2.2.0a1 | 2.3 | :pep:`255`: |
-| | | | *Simple Generators* |
-+------------------+-------------+--------------+---------------------------------------------+
-| division | 2.2.0a2 | 3.0 | :pep:`238`: |
-| | | | *Changing the Division Operator* |
-+------------------+-------------+--------------+---------------------------------------------+
-| absolute_import | 2.5.0a1 | 3.0 | :pep:`328`: |
-| | | | *Imports: Multi-Line and Absolute/Relative* |
-+------------------+-------------+--------------+---------------------------------------------+
-| with_statement | 2.5.0a1 | 2.6 | :pep:`343`: |
-| | | | *The "with" Statement* |
-+------------------+-------------+--------------+---------------------------------------------+
-| print_function | 2.6.0a2 | 3.0 | :pep:`3105`: |
-| | | | *Make print a function* |
-+------------------+-------------+--------------+---------------------------------------------+
-| unicode_literals | 2.6.0a2 | 3.0 | :pep:`3112`: |
-| | | | *Bytes literals in Python 3000* |
-+------------------+-------------+--------------+---------------------------------------------+
-| generator_stop | 3.5.0b1 | 3.7 | :pep:`479`: |
-| | | | *StopIteration handling inside generators* |
-+------------------+-------------+--------------+---------------------------------------------+
-| annotations | 3.7.0b1 | Never [1]_ | :pep:`563`: |
-| | | | *Postponed evaluation of annotations*, |
-| | | | :pep:`649`: *Deferred evaluation of |
-| | | | annotations using descriptors* |
-+------------------+-------------+--------------+---------------------------------------------+
+
+.. list-table::
+ :widths: auto
+ :header-rows: 1
+
+ * * feature
+ * optional in
+ * mandatory in
+ * effect
+ * * .. data:: nested_scopes
+ * 2.1.0b1
+ * 2.2
+ * :pep:`227`: *Statically Nested Scopes*
+ * * .. data:: generators
+ * 2.2.0a1
+ * 2.3
+ * :pep:`255`: *Simple Generators*
+ * * .. data:: division
+ * 2.2.0a2
+ * 3.0
+ * :pep:`238`: *Changing the Division Operator*
+ * * .. data:: absolute_import
+ * 2.5.0a1
+ * 3.0
+ * :pep:`328`: *Imports: Multi-Line and Absolute/Relative*
+ * * .. data:: with_statement
+ * 2.5.0a1
+ * 2.6
+ * :pep:`343`: *The “with” Statement*
+ * * .. data:: print_function
+ * 2.6.0a2
+ * 3.0
+ * :pep:`3105`: *Make print a function*
+ * * .. data:: unicode_literals
+ * 2.6.0a2
+ * 3.0
+ * :pep:`3112`: *Bytes literals in Python 3000*
+ * * .. data:: generator_stop
+ * 3.5.0b1
+ * 3.7
+ * :pep:`479`: *StopIteration handling inside generators*
+ * * .. data:: annotations
+ * 3.7.0b1
+ * Never [1]_
+ * :pep:`563`: *Postponed evaluation of annotations*,
+ :pep:`649`: *Deferred evaluation of annotations using descriptors*
.. XXX Adding a new entry? Remember to update simple_stmts.rst, too.
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index a03d88092db..f189f6b8fa8 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -839,23 +839,11 @@ how the command-line arguments should be handled. The supplied actions are:
>>> parser.parse_args(['--version'])
PROG 2.0
-Only actions that consume command-line arguments (e.g. ``'store'``,
-``'append'`` or ``'extend'``) can be used with positional arguments.
-
-.. class:: BooleanOptionalAction
-
- You may also specify an arbitrary action by passing an :class:`Action` subclass or
- other object that implements the same interface. The :class:`!BooleanOptionalAction`
- is available in :mod:`!argparse` and adds support for boolean actions such as
- ``--foo`` and ``--no-foo``::
-
- >>> import argparse
- >>> parser = argparse.ArgumentParser()
- >>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
- >>> parser.parse_args(['--no-foo'])
- Namespace(foo=False)
-
- .. versionadded:: 3.9
+You may also specify an arbitrary action by passing an :class:`Action` subclass
+(e.g. :class:`BooleanOptionalAction`) or other object that implements the same
+interface. Only actions that consume command-line arguments (e.g. ``'store'``,
+``'append'``, ``'extend'``, or custom actions with non-zero ``nargs``) can be used
+with positional arguments.
The recommended way to create a custom action is to extend :class:`Action`,
overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` and
@@ -1429,6 +1417,21 @@ this API may be passed as the ``action`` parameter to
and return a string which will be used when printing the usage of the program.
If such method is not provided, a sensible default will be used.
+.. class:: BooleanOptionalAction
+
+ A subclass of :class:`Action` for handling boolean flags with positive
+ and negative options. Adding a single argument such as ``--foo`` automatically
+ creates both ``--foo`` and ``--no-foo`` options, storing ``True`` and ``False``
+ respectively::
+
+ >>> import argparse
+ >>> parser = argparse.ArgumentParser()
+ >>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
+ >>> parser.parse_args(['--no-foo'])
+ Namespace(foo=False)
+
+ .. versionadded:: 3.9
+
The parse_args() method
-----------------------
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index b231fa568cf..0e84f18dd4d 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -265,6 +265,20 @@ wider range of codecs when working with binary files:
:func:`iterencode`.
+.. function:: readbuffer_encode(buffer, errors=None, /)
+
+ Return a :class:`tuple` containing the raw bytes of *buffer*, a
+ :ref:`buffer-compatible object <bufferobjects>` or :class:`str`
+ (encoded to UTF-8 before processing), and their length in bytes.
+
+ The *errors* argument is ignored.
+
+ .. code-block:: pycon
+
+ >>> codecs.readbuffer_encode(b"Zito")
+ (b'Zito', 4)
+
+
The module also provides the following constants which are useful for reading
and writing to platform dependent files:
@@ -1484,6 +1498,66 @@ mapping. It is not supported by :meth:`str.encode` (which only produces
Restoration of the ``rot13`` alias.
+:mod:`encodings` --- Encodings package
+--------------------------------------
+
+.. module:: encodings
+ :synopsis: Encodings package
+
+This module implements the following functions:
+
+.. function:: normalize_encoding(encoding)
+
+ Normalize encoding name *encoding*.
+
+ Normalization works as follows: all non-alphanumeric characters except the
+ dot used for Python package names are collapsed and replaced with a single
+ underscore, leading and trailing underscores are removed.
+ For example, ``' -;#'`` becomes ``'_'``.
+
+ Note that *encoding* should be ASCII only.
+
+
+.. note::
+ The following functions should not be used directly, except for testing
+ purposes; :func:`codecs.lookup` should be used instead.
+
+
+.. function:: search_function(encoding)
+
+ Search for the codec module corresponding to the given encoding name
+ *encoding*.
+
+ This function first normalizes the *encoding* using
+ :func:`normalize_encoding`, then looks for a corresponding alias.
+ It attempts to import a codec module from the encodings package using either
+ the alias or the normalized name. If the module is found and defines a valid
+ ``getregentry()`` function that returns a :class:`codecs.CodecInfo` object,
+ the codec is cached and returned.
+
+ If the codec module defines a ``getaliases()`` function any returned aliases
+ are registered for future use.
+
+
+.. function:: win32_code_page_search_function(encoding)
+
+ Search for a Windows code page encoding *encoding* of the form ``cpXXXX``.
+
+ If the code page is valid and supported, return a :class:`codecs.CodecInfo`
+ object for it.
+
+ .. availability:: Windows.
+
+ .. versionadded:: 3.14
+
+
+This module implements the following exception:
+
+.. exception:: CodecRegistryError
+
+ Raised when a codec is invalid or incompatible.
+
+
:mod:`encodings.idna` --- Internationalized Domain Names in Applications
------------------------------------------------------------------------
diff --git a/Doc/library/email.compat32-message.rst b/Doc/library/email.compat32-message.rst
index 4285c436e8d..5754c2b65b2 100644
--- a/Doc/library/email.compat32-message.rst
+++ b/Doc/library/email.compat32-message.rst
@@ -181,7 +181,7 @@ Here are the methods of the :class:`Message` class:
:meth:`set_payload` instead.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by :meth:`~email.message.EmailMessage.set_content` and the
related ``make`` and ``add`` methods.
@@ -224,7 +224,7 @@ Here are the methods of the :class:`Message` class:
ASCII charset.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by :meth:`~email.message.EmailMessage.get_content` and
:meth:`~email.message.EmailMessage.iter_parts`.
@@ -236,7 +236,7 @@ Here are the methods of the :class:`Message` class:
the message's default character set; see :meth:`set_charset` for details.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by :meth:`~email.message.EmailMessage.set_content`.
@@ -265,9 +265,9 @@ Here are the methods of the :class:`Message` class:
using that :mailheader:`Content-Transfer-Encoding` and is not modified.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by the *charset* parameter of the
- :meth:`email.emailmessage.EmailMessage.set_content` method.
+ :meth:`email.message.EmailMessage.set_content` method.
.. method:: get_charset()
@@ -276,7 +276,7 @@ Here are the methods of the :class:`Message` class:
message's payload.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class it always returns
+ :class:`~email.message.EmailMessage` class it always returns
``None``.
@@ -486,7 +486,7 @@ Here are the methods of the :class:`Message` class:
search instead of :mailheader:`Content-Type`.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by the *params* property of the individual header objects
returned by the header access methods.
@@ -524,7 +524,7 @@ Here are the methods of the :class:`Message` class:
to ``False``.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by the *params* property of the individual header objects
returned by the header access methods.
@@ -579,7 +579,7 @@ Here are the methods of the :class:`Message` class:
header is also added.
This is a legacy method. On the
- :class:`~email.emailmessage.EmailMessage` class its functionality is
+ :class:`~email.message.EmailMessage` class its functionality is
replaced by the ``make_`` and ``add_`` methods.
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index c09e1615a5b..a73cc2e8a2d 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -204,10 +204,16 @@ The following exceptions are the exceptions that are usually raised.
assignment fails. (When an object does not support attribute references or
attribute assignments at all, :exc:`TypeError` is raised.)
- The :attr:`name` and :attr:`obj` attributes can be set using keyword-only
- arguments to the constructor. When set they represent the name of the attribute
- that was attempted to be accessed and the object that was accessed for said
- attribute, respectively.
+ The optional *name* and *obj* keyword-only arguments
+ set the corresponding attributes:
+
+ .. attribute:: name
+
+ The name of the attribute that was attempted to be accessed.
+
+ .. attribute:: obj
+
+ The object that was accessed for the named attribute.
.. versionchanged:: 3.10
Added the :attr:`name` and :attr:`obj` attributes.
@@ -215,7 +221,7 @@ The following exceptions are the exceptions that are usually raised.
.. exception:: EOFError
Raised when the :func:`input` function hits an end-of-file condition (EOF)
- without reading any data. (N.B.: the :meth:`io.IOBase.read` and
+ without reading any data. (Note: the :meth:`!io.IOBase.read` and
:meth:`io.IOBase.readline` methods return an empty string when they hit EOF.)
@@ -312,9 +318,11 @@ The following exceptions are the exceptions that are usually raised.
unqualified names. The associated value is an error message that includes the
name that could not be found.
- The :attr:`name` attribute can be set using a keyword-only argument to the
- constructor. When set it represent the name of the variable that was attempted
- to be accessed.
+ The optional *name* keyword-only argument sets the attribute:
+
+ .. attribute:: name
+
+ The name of the variable that was attempted to be accessed.
.. versionchanged:: 3.10
Added the :attr:`name` attribute.
@@ -382,7 +390,7 @@ The following exceptions are the exceptions that are usually raised.
The corresponding error message, as provided by
the operating system. It is formatted by the C
- functions :c:func:`perror` under POSIX, and :c:func:`FormatMessage`
+ functions :c:func:`!perror` under POSIX, and :c:func:`!FormatMessage`
under Windows.
.. attribute:: filename
@@ -398,7 +406,7 @@ The following exceptions are the exceptions that are usually raised.
.. versionchanged:: 3.3
:exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`,
:exc:`socket.error`, :exc:`select.error` and
- :exc:`mmap.error` have been merged into :exc:`OSError`, and the
+ :exc:`!mmap.error` have been merged into :exc:`OSError`, and the
constructor may return a subclass.
.. versionchanged:: 3.4
@@ -597,7 +605,7 @@ The following exceptions are the exceptions that are usually raised.
handled, the Python interpreter exits; no stack traceback is printed. The
constructor accepts the same optional argument passed to :func:`sys.exit`.
If the value is an integer, it specifies the system exit status (passed to
- C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if
+ C's :c:func:`!exit` function); if it is ``None``, the exit status is zero; if
it has another type (such as a string), the object's value is printed and
the exit status is one.
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index fc3c1134f97..546876bd925 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -1118,7 +1118,9 @@ Miscellaneous
Return a context object which has the same attributes as the
:mod:`multiprocessing` module.
- If *method* is ``None`` then the default context is returned.
+ If *method* is ``None`` then the default context is returned. Note that if
+ the global start method has not been set, this will set it to the
+ default method.
Otherwise *method* should be ``'fork'``, ``'spawn'``,
``'forkserver'``. :exc:`ValueError` is raised if the specified
start method is not available. See :ref:`multiprocessing-start-methods`.
@@ -1129,10 +1131,10 @@ Miscellaneous
Return the name of start method used for starting processes.
- If the start method has not been fixed and *allow_none* is false,
- then the start method is fixed to the default and the name is
- returned. If the start method has not been fixed and *allow_none*
- is true then ``None`` is returned.
+ If the global start method has not been set and *allow_none* is
+ ``False``, then the start method is set to the default and the name
+ is returned. If the start method has not been set and *allow_none* is
+ ``True`` then ``None`` is returned.
The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'``
or ``None``. See :ref:`multiprocessing-start-methods`.
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index f72aee19d8f..1c1cf07a655 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -298,9 +298,10 @@ the :mod:`glob` module.)
device than *path*, or whether :file:`{path}/..` and *path* point to the same
i-node on the same device --- this should detect mount points for all Unix
and POSIX variants. It is not able to reliably detect bind mounts on the
- same filesystem. On Windows, a drive letter root and a share UNC are
- always mount points, and for any other path ``GetVolumePathName`` is called
- to see if it is different from the input path.
+ same filesystem. On Linux systems, it will always return ``True`` for btrfs
+ subvolumes, even if they aren't mount points. On Windows, a drive letter root
+ and a share UNC are always mount points, and for any other path
+ ``GetVolumePathName`` is called to see if it is different from the input path.
.. versionchanged:: 3.4
Added support for detecting non-root mount points on Windows.
diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst
index 2d57cff10a9..5506ac828e5 100644
--- a/Doc/library/pyexpat.rst
+++ b/Doc/library/pyexpat.rst
@@ -16,11 +16,10 @@
references to these attributes should be marked using the :member: role.
-.. warning::
+.. note::
- The :mod:`pyexpat` module is not secure against maliciously
- constructed data. If you need to parse untrusted or unauthenticated data see
- :ref:`xml-vulnerabilities`.
+ If you need to parse untrusted or unauthenticated data, see
+ :ref:`xml-security`.
.. index:: single: Expat
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index ef0cfb0e76c..b1120b3a4d8 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -447,6 +447,11 @@ Alternative Generator
Override this method in subclasses to customise the
:meth:`~random.getrandbits` behaviour of :class:`!Random` instances.
+ .. method:: Random.randbytes(n)
+
+ Override this method in subclasses to customise the
+ :meth:`~random.randbytes` behaviour of :class:`!Random` instances.
+
.. class:: SystemRandom([seed])
diff --git a/Doc/library/security_warnings.rst b/Doc/library/security_warnings.rst
index a573c98f73e..70c359cc1c0 100644
--- a/Doc/library/security_warnings.rst
+++ b/Doc/library/security_warnings.rst
@@ -28,7 +28,7 @@ The following modules have specific security considerations:
<subprocess-security>`
* :mod:`tempfile`: :ref:`mktemp is deprecated due to vulnerability to race
conditions <tempfile-mktemp-deprecated>`
-* :mod:`xml`: :ref:`XML vulnerabilities <xml-vulnerabilities>`
+* :mod:`xml`: :ref:`XML security <xml-security>`
* :mod:`zipfile`: :ref:`maliciously prepared .zip files can cause disk volume
exhaustion <zipfile-resources-limitations>`
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 641e1f1de03..a14af6d3d88 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -2288,7 +2288,7 @@ This section shows recipes for common adapters and converters.
def adapt_datetime_iso(val):
"""Adapt datetime.datetime to timezone-naive ISO 8601 date."""
- return val.isoformat()
+ return val.replace(tzinfo=None).isoformat()
def adapt_datetime_epoch(val):
"""Adapt datetime.datetime to Unix timestamp."""
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 1626a89a073..05bc7cfb9dc 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -953,6 +953,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only
This function should be used for internal and specialized purposes only.
It is not guaranteed to exist in all implementations of Python.
+ .. versionadded:: 3.12
+
.. function:: getobjects(limit[, type])
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index d526e835caa..ec96e841612 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -2563,7 +2563,7 @@ To add cleanup code that must be run even in the case of an exception, use
.. versionadded:: 3.8
-.. classmethod:: enterModuleContext(cm)
+.. function:: enterModuleContext(cm)
Enter the supplied :term:`context manager`. If successful, also
add its :meth:`~object.__exit__` method as a cleanup function by
diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst
index 00a18751207..9ffedf7366a 100644
--- a/Doc/library/xml.dom.minidom.rst
+++ b/Doc/library/xml.dom.minidom.rst
@@ -19,11 +19,10 @@ not already proficient with the DOM should consider using the
:mod:`xml.etree.ElementTree` module for their XML processing instead.
-.. warning::
+.. note::
- The :mod:`xml.dom.minidom` module is not secure against
- maliciously constructed data. If you need to parse untrusted or
- unauthenticated data see :ref:`xml-vulnerabilities`.
+ If you need to parse untrusted or unauthenticated data, see
+ :ref:`xml-security`.
DOM applications typically start by parsing some XML into a DOM. With
diff --git a/Doc/library/xml.dom.pulldom.rst b/Doc/library/xml.dom.pulldom.rst
index fd96765cbe3..8bceeecd463 100644
--- a/Doc/library/xml.dom.pulldom.rst
+++ b/Doc/library/xml.dom.pulldom.rst
@@ -19,11 +19,10 @@ responsible for explicitly pulling events from the stream, looping over those
events until either processing is finished or an error condition occurs.
-.. warning::
+.. note::
- The :mod:`xml.dom.pulldom` module is not secure against
- maliciously constructed data. If you need to parse untrusted or
- unauthenticated data see :ref:`xml-vulnerabilities`.
+ If you need to parse untrusted or unauthenticated data, see
+ :ref:`xml-security`.
.. versionchanged:: 3.7.1
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index 1daf6628013..00075ac2a23 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -20,11 +20,10 @@ for parsing and creating XML data.
The :mod:`!xml.etree.cElementTree` module is deprecated.
-.. warning::
+.. note::
- The :mod:`xml.etree.ElementTree` module is not secure against
- maliciously constructed data. If you need to parse untrusted or
- unauthenticated data see :ref:`xml-vulnerabilities`.
+ If you need to parse untrusted or unauthenticated data, see
+ :ref:`xml-security`.
Tutorial
--------
diff --git a/Doc/library/xml.rst b/Doc/library/xml.rst
index d4959953989..28465219a1a 100644
--- a/Doc/library/xml.rst
+++ b/Doc/library/xml.rst
@@ -15,12 +15,10 @@ XML Processing Modules
Python's interfaces for processing XML are grouped in the ``xml`` package.
-.. warning::
+.. note::
- The XML modules are not secure against erroneous or maliciously
- constructed data. If you need to parse untrusted or
- unauthenticated data see the :ref:`xml-vulnerabilities` and
- :ref:`defusedxml-package` sections.
+ If you need to parse untrusted or unauthenticated data, see
+ :ref:`xml-security`.
It is important to note that modules in the :mod:`xml` package require that
there be at least one SAX-compliant XML parser available. The Expat parser is
@@ -47,46 +45,22 @@ The XML handling submodules are:
* :mod:`xml.parsers.expat`: the Expat parser binding
+.. _xml-security:
.. _xml-vulnerabilities:
-XML vulnerabilities
--------------------
+XML security
+------------
-The XML processing modules are not secure against maliciously constructed data.
An attacker can abuse XML features to carry out denial of service attacks,
access local files, generate network connections to other machines, or
circumvent firewalls.
-The following table gives an overview of the known attacks and whether
-the various modules are vulnerable to them.
-
-========================= ================== ================== ================== ================== ==================
-kind sax etree minidom pulldom xmlrpc
-========================= ================== ================== ================== ================== ==================
-billion laughs **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1)
-quadratic blowup **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1) **Vulnerable** (1)
-external entity expansion Safe (5) Safe (2) Safe (3) Safe (5) Safe (4)
-`DTD`_ retrieval Safe (5) Safe Safe Safe (5) Safe
-decompression bomb Safe Safe Safe Safe **Vulnerable**
-large tokens **Vulnerable** (6) **Vulnerable** (6) **Vulnerable** (6) **Vulnerable** (6) **Vulnerable** (6)
-========================= ================== ================== ================== ================== ==================
-
-1. Expat 2.4.1 and newer is not vulnerable to the "billion laughs" and
- "quadratic blowup" vulnerabilities. Items still listed as vulnerable due to
- potential reliance on system-provided libraries. Check
- :const:`!pyexpat.EXPAT_VERSION`.
-2. :mod:`xml.etree.ElementTree` doesn't expand external entities and raises a
- :exc:`~xml.etree.ElementTree.ParseError` when an entity occurs.
-3. :mod:`xml.dom.minidom` doesn't expand external entities and simply returns
- the unexpanded entity verbatim.
-4. :mod:`xmlrpc.client` doesn't expand external entities and omits them.
-5. Since Python 3.7.1, external general entities are no longer processed by
- default.
-6. Expat 2.6.0 and newer is not vulnerable to denial of service
- through quadratic runtime caused by parsing large tokens.
- Items still listed as vulnerable due to
- potential reliance on system-provided libraries. Check
- :const:`!pyexpat.EXPAT_VERSION`.
+Expat versions lower that 2.6.0 may be vulnerable to "billion laughs",
+"quadratic blowup" and "large tokens". Python may be vulnerable if it uses such
+older versions of Expat as a system-provided library.
+Check :const:`!pyexpat.EXPAT_VERSION`.
+
+:mod:`xmlrpc` is **vulnerable** to the "decompression bomb" attack.
billion laughs / exponential entity expansion
@@ -103,16 +77,6 @@ quadratic blowup entity expansion
efficient as the exponential case but it avoids triggering parser countermeasures
that forbid deeply nested entities.
-external entity expansion
- Entity declarations can contain more than just text for replacement. They can
- also point to external resources or local files. The XML
- parser accesses the resource and embeds the content into the XML document.
-
-`DTD`_ retrieval
- Some XML libraries like Python's :mod:`xml.dom.pulldom` retrieve document type
- definitions from remote or local locations. The feature has similar
- implications as the external entity expansion issue.
-
decompression bomb
Decompression bombs (aka `ZIP bomb`_) apply to all XML libraries
that can parse compressed XML streams such as gzipped HTTP streams or
@@ -126,21 +90,5 @@ large tokens
be used to cause denial of service in the application parsing XML.
The issue is known as :cve:`2023-52425`.
-The documentation for :pypi:`defusedxml` on PyPI has further information about
-all known attack vectors with examples and references.
-
-.. _defusedxml-package:
-
-The :mod:`!defusedxml` Package
-------------------------------
-
-:pypi:`defusedxml` is a pure Python package with modified subclasses of all stdlib
-XML parsers that prevent any potentially malicious operation. Use of this
-package is recommended for any server code that parses untrusted XML data. The
-package also ships with example exploits and extended documentation on more
-XML exploits such as XPath injection.
-
-
.. _Billion Laughs: https://en.wikipedia.org/wiki/Billion_laughs
.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb
-.. _DTD: https://en.wikipedia.org/wiki/Document_type_definition
diff --git a/Doc/library/xml.sax.rst b/Doc/library/xml.sax.rst
index c60e9e505f7..5fa92645a44 100644
--- a/Doc/library/xml.sax.rst
+++ b/Doc/library/xml.sax.rst
@@ -18,11 +18,10 @@ SAX exceptions and the convenience functions which will be most used by users of
the SAX API.
-.. warning::
+.. note::
- The :mod:`xml.sax` module is not secure against maliciously
- constructed data. If you need to parse untrusted or unauthenticated data see
- :ref:`xml-vulnerabilities`.
+ If you need to parse untrusted or unauthenticated data, see
+ :ref:`xml-security`.
.. versionchanged:: 3.7.1
diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst
index 654154cb43d..547cb50be78 100644
--- a/Doc/library/xmlrpc.client.rst
+++ b/Doc/library/xmlrpc.client.rst
@@ -24,8 +24,8 @@ between conformable Python objects and XML on the wire.
.. warning::
The :mod:`xmlrpc.client` module is not secure against maliciously
- constructed data. If you need to parse untrusted or unauthenticated data see
- :ref:`xml-vulnerabilities`.
+ constructed data. If you need to parse untrusted or unauthenticated data,
+ see :ref:`xml-security`.
.. versionchanged:: 3.5
diff --git a/Doc/library/xmlrpc.server.rst b/Doc/library/xmlrpc.server.rst
index 06169c7eca8..2a8f6f8d5fc 100644
--- a/Doc/library/xmlrpc.server.rst
+++ b/Doc/library/xmlrpc.server.rst
@@ -20,8 +20,8 @@ servers written in Python. Servers can either be free standing, using
.. warning::
The :mod:`xmlrpc.server` module is not secure against maliciously
- constructed data. If you need to parse untrusted or unauthenticated data see
- :ref:`xml-vulnerabilities`.
+ constructed data. If you need to parse untrusted or unauthenticated data,
+ see :ref:`xml-security`.
.. include:: ../includes/wasm-notavail.rst
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index e3bcb968128..4f5396857f3 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -15,9 +15,7 @@ Doc/extending/extending.rst
Doc/library/ast.rst
Doc/library/asyncio-extending.rst
Doc/library/email.charset.rst
-Doc/library/email.compat32-message.rst
Doc/library/email.parser.rst
-Doc/library/exceptions.rst
Doc/library/functools.rst
Doc/library/http.cookiejar.rst
Doc/library/http.server.rst
@@ -73,6 +71,4 @@ Doc/whatsnew/3.5.rst
Doc/whatsnew/3.6.rst
Doc/whatsnew/3.7.rst
Doc/whatsnew/3.8.rst
-Doc/whatsnew/3.9.rst
Doc/whatsnew/3.10.rst
-Doc/whatsnew/3.11.rst
diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst
index a26d48d7d0a..e5fe3c72b1b 100644
--- a/Doc/using/configure.rst
+++ b/Doc/using/configure.rst
@@ -686,6 +686,13 @@ also be used to improve performance.
not compiled. This includes both the functionality to schedule code to be executed
and the functionality to receive code to be executed.
+ .. c:macro:: Py_REMOTE_DEBUG
+
+ This macro is defined by default, unless Python is configured with
+ :option:`--without-remote-debug`.
+
+ Note that even if the macro is defined, remote debugging may not be
+ available (for example, on an incompatible platform).
.. versionadded:: 3.14
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 2dd205dd2b8..abf9677fd9c 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -1292,7 +1292,7 @@ This section covers specific optimizations independent of the
(Contributed by Stefan Behnel in :gh:`68264`.)
* Resizing lists is streamlined for the common case,
- speeding up :meth:`list.append` by ≈15%
+ speeding up :meth:`!list.append` by ≈15%
and simple :term:`list comprehension`\s by up to 20-30%
(Contributed by Dennis Sweeney in :gh:`91165`.)
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 896e8f4a489..40d4a27bff9 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -423,8 +423,8 @@ digests. It skips MD5 on platforms that block MD5 digest.
fcntl
-----
-Added constants :const:`~fcntl.F_OFD_GETLK`, :const:`~fcntl.F_OFD_SETLK`
-and :const:`~fcntl.F_OFD_SETLKW`.
+Added constants :const:`!fcntl.F_OFD_GETLK`, :const:`!fcntl.F_OFD_SETLK`
+and :const:`!fcntl.F_OFD_SETLKW`.
(Contributed by Donghee Na in :issue:`38602`.)
ftplib
@@ -644,7 +644,7 @@ attribute.
random
------
-Added a new :attr:`random.Random.randbytes` method: generate random bytes.
+Added a new :meth:`random.Random.randbytes` method: generate random bytes.
(Contributed by Victor Stinner in :issue:`40286`.)
signal
@@ -776,7 +776,7 @@ Optimizations
:pep:`590` vectorcall protocol.
(Contributed by Donghee Na, Mark Shannon, Jeroen Demeyer and Petr Viktorin in :issue:`37207`.)
-* Optimized :func:`~set.difference_update` for the case when the other set
+* Optimized :meth:`!set.difference_update` for the case when the other set
is much larger than the base set.
(Suggested by Evgeny Kapun with code contributed by Michele Orrù in :issue:`8425`.)