Skip to content

Commit fde43e2

Browse files
committed
Deploying to gh-pages from @ d785c51 🚀
1 parent 922a6b5 commit fde43e2

File tree

567 files changed

+1923
-1392
lines changed

Some content is hidden

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

567 files changed

+1923
-1392
lines changed

_sources/c-api/exceptions.rst.txt

Lines changed: 187 additions & 251 deletions
Large diffs are not rendered by default.

_sources/glossary.rst.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,16 @@ Glossary
12351235
and ending with double underscores. Special methods are documented in
12361236
:ref:`specialnames`.
12371237

1238+
standard library
1239+
The collection of :term:`packages <package>`, :term:`modules <module>`
1240+
and :term:`extension modules <extension module>` distributed as a part
1241+
of the official Python interpreter package. The exact membership of the
1242+
collection may vary based on platform, available system libraries, or
1243+
other criteria. Documentation can be found at :ref:`library-index`.
1244+
1245+
See also :data:`sys.stdlib_module_names` for a list of all possible
1246+
standard library module names.
1247+
12381248
statement
12391249
A statement is part of a suite (a "block" of code). A statement is either
12401250
an :term:`expression` or one of several constructs with a keyword, such
@@ -1245,6 +1255,9 @@ Glossary
12451255
issues such as incorrect types. See also :term:`type hints <type hint>`
12461256
and the :mod:`typing` module.
12471257

1258+
stdlib
1259+
An abbreviation of :term:`standard library`.
1260+
12481261
strong reference
12491262
In Python's C API, a strong reference is a reference to an object
12501263
which is owned by the code holding the reference. The strong

_sources/howto/logging-cookbook.rst.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4127,6 +4127,42 @@ The script, when run, prints something like:
41274127
2025-07-02 13:54:47,234 DEBUG fool me ...
41284128
2025-07-02 13:54:47,234 DEBUG can't get fooled again
41294129
4130+
If, on the other hand, you are concerned about `log injection
4131+
<https://owasp.org/www-community/attacks/Log_Injection>`_, you can use a
4132+
formatter which escapes newlines, as per the following example:
4133+
4134+
.. code-block:: python
4135+
4136+
import logging
4137+
4138+
logger = logging.getLogger(__name__)
4139+
4140+
class EscapingFormatter(logging.Formatter):
4141+
def format(self, record):
4142+
s = super().format(record)
4143+
return s.replace('\n', r'\n')
4144+
4145+
if __name__ == '__main__':
4146+
h = logging.StreamHandler()
4147+
h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s'))
4148+
logging.basicConfig(level=logging.DEBUG, handlers = [h])
4149+
logger.debug('Single line')
4150+
logger.debug('Multiple lines:\nfool me once ...')
4151+
logger.debug('Another single line')
4152+
logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again')
4153+
4154+
You can, of course, use whatever escaping scheme makes the most sense for you.
4155+
The script, when run, should produce output like this:
4156+
4157+
.. code-block:: text
4158+
4159+
2025-07-09 06:47:33,783 DEBUG Single line
4160+
2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me once ...
4161+
2025-07-09 06:47:33,783 DEBUG Another single line
4162+
2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me ...\ncan't get fooled again
4163+
4164+
Escaping behaviour can't be the stdlib default , as it would break backwards
4165+
compatibility.
41304166

41314167
.. patterns-to-avoid:
41324168

_sources/library/argparse.rst.txt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -744,23 +744,11 @@ how the command-line arguments should be handled. The supplied actions are:
744744
>>> parser.parse_args(['--version'])
745745
PROG 2.0
746746

747-
Only actions that consume command-line arguments (e.g. ``'store'``,
748-
``'append'`` or ``'extend'``) can be used with positional arguments.
749-
750-
.. class:: BooleanOptionalAction
751-
752-
You may also specify an arbitrary action by passing an :class:`Action` subclass or
753-
other object that implements the same interface. The :class:`!BooleanOptionalAction`
754-
is available in :mod:`!argparse` and adds support for boolean actions such as
755-
``--foo`` and ``--no-foo``::
756-
757-
>>> import argparse
758-
>>> parser = argparse.ArgumentParser()
759-
>>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
760-
>>> parser.parse_args(['--no-foo'])
761-
Namespace(foo=False)
762-
763-
.. versionadded:: 3.9
747+
You may also specify an arbitrary action by passing an :class:`Action` subclass
748+
(e.g. :class:`BooleanOptionalAction`) or other object that implements the same
749+
interface. Only actions that consume command-line arguments (e.g. ``'store'``,
750+
``'append'``, ``'extend'``, or custom actions with non-zero ``nargs``) can be used
751+
with positional arguments.
764752

765753
The recommended way to create a custom action is to extend :class:`Action`,
766754
overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` and
@@ -1337,6 +1325,21 @@ this API may be passed as the ``action`` parameter to
13371325
and return a string which will be used when printing the usage of the program.
13381326
If such method is not provided, a sensible default will be used.
13391327

1328+
.. class:: BooleanOptionalAction
1329+
1330+
A subclass of :class:`Action` for handling boolean flags with positive
1331+
and negative options. Adding a single argument such as ``--foo`` automatically
1332+
creates both ``--foo`` and ``--no-foo`` options, storing ``True`` and ``False``
1333+
respectively::
1334+
1335+
>>> import argparse
1336+
>>> parser = argparse.ArgumentParser()
1337+
>>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
1338+
>>> parser.parse_args(['--no-foo'])
1339+
Namespace(foo=False)
1340+
1341+
.. versionadded:: 3.9
1342+
13401343

13411344
The parse_args() method
13421345
-----------------------

_sources/library/codecs.rst.txt

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ wider range of codecs when working with binary files:
239239
.. function:: iterencode(iterator, encoding, errors='strict', **kwargs)
240240

241241
Uses an incremental encoder to iteratively encode the input provided by
242-
*iterator*. This function is a :term:`generator`.
243-
The *errors* argument (as well as any
242+
*iterator*. *iterator* must yield :class:`str` objects.
243+
This function is a :term:`generator`. The *errors* argument (as well as any
244244
other keyword argument) is passed through to the incremental encoder.
245245

246246
This function requires that the codec accept text :class:`str` objects
@@ -251,8 +251,8 @@ wider range of codecs when working with binary files:
251251
.. function:: iterdecode(iterator, encoding, errors='strict', **kwargs)
252252

253253
Uses an incremental decoder to iteratively decode the input provided by
254-
*iterator*. This function is a :term:`generator`.
255-
The *errors* argument (as well as any
254+
*iterator*. *iterator* must yield :class:`bytes` objects.
255+
This function is a :term:`generator`. The *errors* argument (as well as any
256256
other keyword argument) is passed through to the incremental decoder.
257257

258258
This function requires that the codec accept :class:`bytes` objects
@@ -261,6 +261,20 @@ wider range of codecs when working with binary files:
261261
:func:`iterencode`.
262262

263263

264+
.. function:: readbuffer_encode(buffer, errors=None, /)
265+
266+
Return a :class:`tuple` containing the raw bytes of *buffer*, a
267+
:ref:`buffer-compatible object <bufferobjects>` or :class:`str`
268+
(encoded to UTF-8 before processing), and their length in bytes.
269+
270+
The *errors* argument is ignored.
271+
272+
.. code-block:: pycon
273+
274+
>>> codecs.readbuffer_encode(b"Zito")
275+
(b'Zito', 4)
276+
277+
264278
The module also provides the following constants which are useful for reading
265279
and writing to platform dependent files:
266280

@@ -1473,6 +1487,54 @@ mapping. It is not supported by :meth:`str.encode` (which only produces
14731487
Restoration of the ``rot13`` alias.
14741488

14751489

1490+
:mod:`encodings` --- Encodings package
1491+
--------------------------------------
1492+
1493+
.. module:: encodings
1494+
:synopsis: Encodings package
1495+
1496+
This module implements the following functions:
1497+
1498+
.. function:: normalize_encoding(encoding)
1499+
1500+
Normalize encoding name *encoding*.
1501+
1502+
Normalization works as follows: all non-alphanumeric characters except the
1503+
dot used for Python package names are collapsed and replaced with a single
1504+
underscore, leading and trailing underscores are removed.
1505+
For example, ``' -;#'`` becomes ``'_'``.
1506+
1507+
Note that *encoding* should be ASCII only.
1508+
1509+
1510+
.. note::
1511+
The following function should not be used directly, except for testing
1512+
purposes; :func:`codecs.lookup` should be used instead.
1513+
1514+
1515+
.. function:: search_function(encoding)
1516+
1517+
Search for the codec module corresponding to the given encoding name
1518+
*encoding*.
1519+
1520+
This function first normalizes the *encoding* using
1521+
:func:`normalize_encoding`, then looks for a corresponding alias.
1522+
It attempts to import a codec module from the encodings package using either
1523+
the alias or the normalized name. If the module is found and defines a valid
1524+
``getregentry()`` function that returns a :class:`codecs.CodecInfo` object,
1525+
the codec is cached and returned.
1526+
1527+
If the codec module defines a ``getaliases()`` function any returned aliases
1528+
are registered for future use.
1529+
1530+
1531+
This module implements the following exception:
1532+
1533+
.. exception:: CodecRegistryError
1534+
1535+
Raised when a codec is invalid or incompatible.
1536+
1537+
14761538
:mod:`encodings.idna` --- Internationalized Domain Names in Applications
14771539
------------------------------------------------------------------------
14781540

_sources/library/email.parser.rst.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ methods.
4848
FeedParser API
4949
^^^^^^^^^^^^^^
5050

51-
The :class:`BytesFeedParser`, imported from the :mod:`email.feedparser` module,
52-
provides an API that is conducive to incremental parsing of email messages,
51+
The :class:`BytesFeedParser`, imported from the :mod:`email.parser.FeedParser`
52+
module, provides an API that is conducive to incremental parsing of email messages,
5353
such as would be necessary when reading the text of an email message from a
5454
source that can block (such as a socket). The :class:`BytesFeedParser` can of
5555
course be used to parse an email message fully contained in a :term:`bytes-like
@@ -116,7 +116,7 @@ Here is the API for the :class:`BytesFeedParser`:
116116
Works like :class:`BytesFeedParser` except that the input to the
117117
:meth:`~BytesFeedParser.feed` method must be a string. This is of limited
118118
utility, since the only way for such a message to be valid is for it to
119-
contain only ASCII text or, if :attr:`~email.policy.Policy.utf8` is
119+
contain only ASCII text or, if :attr:`~email.policy.EmailPolicy.utf8` is
120120
``True``, no binary attachments.
121121

122122
.. versionchanged:: 3.3 Added the *policy* keyword.
@@ -155,11 +155,11 @@ message body, instead setting the payload to the raw body.
155155

156156
Read all the data from the binary file-like object *fp*, parse the
157157
resulting bytes, and return the message object. *fp* must support
158-
both the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read`
158+
both the :meth:`~io.IOBase.readline` and the :meth:`~io.TextIOBase.read`
159159
methods.
160160

161161
The bytes contained in *fp* must be formatted as a block of :rfc:`5322`
162-
(or, if :attr:`~email.policy.Policy.utf8` is ``True``, :rfc:`6532`)
162+
(or, if :attr:`~email.policy.EmailPolicy.utf8` is ``True``, :rfc:`6532`)
163163
style headers and header continuation lines, optionally preceded by an
164164
envelope header. The header block is terminated either by the end of the
165165
data or by a blank line. Following the header block is the body of the

_sources/library/exceptions.rst.txt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,24 @@ The following exceptions are the exceptions that are usually raised.
204204
assignment fails. (When an object does not support attribute references or
205205
attribute assignments at all, :exc:`TypeError` is raised.)
206206

207-
The :attr:`name` and :attr:`obj` attributes can be set using keyword-only
208-
arguments to the constructor. When set they represent the name of the attribute
209-
that was attempted to be accessed and the object that was accessed for said
210-
attribute, respectively.
207+
The optional *name* and *obj* keyword-only arguments
208+
set the corresponding attributes:
209+
210+
.. attribute:: name
211+
212+
The name of the attribute that was attempted to be accessed.
213+
214+
.. attribute:: obj
215+
216+
The object that was accessed for the named attribute.
211217

212218
.. versionchanged:: 3.10
213219
Added the :attr:`name` and :attr:`obj` attributes.
214220

215221
.. exception:: EOFError
216222

217223
Raised when the :func:`input` function hits an end-of-file condition (EOF)
218-
without reading any data. (N.B.: the :meth:`io.IOBase.read` and
224+
without reading any data. (Note: the :meth:`!io.IOBase.read` and
219225
:meth:`io.IOBase.readline` methods return an empty string when they hit EOF.)
220226

221227

@@ -312,9 +318,11 @@ The following exceptions are the exceptions that are usually raised.
312318
unqualified names. The associated value is an error message that includes the
313319
name that could not be found.
314320

315-
The :attr:`name` attribute can be set using a keyword-only argument to the
316-
constructor. When set it represent the name of the variable that was attempted
317-
to be accessed.
321+
The optional *name* keyword-only argument sets the attribute:
322+
323+
.. attribute:: name
324+
325+
The name of the variable that was attempted to be accessed.
318326

319327
.. versionchanged:: 3.10
320328
Added the :attr:`name` attribute.
@@ -382,7 +390,7 @@ The following exceptions are the exceptions that are usually raised.
382390

383391
The corresponding error message, as provided by
384392
the operating system. It is formatted by the C
385-
functions :c:func:`perror` under POSIX, and :c:func:`FormatMessage`
393+
functions :c:func:`!perror` under POSIX, and :c:func:`!FormatMessage`
386394
under Windows.
387395

388396
.. attribute:: filename
@@ -398,7 +406,7 @@ The following exceptions are the exceptions that are usually raised.
398406
.. versionchanged:: 3.3
399407
:exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`,
400408
:exc:`socket.error`, :exc:`select.error` and
401-
:exc:`mmap.error` have been merged into :exc:`OSError`, and the
409+
:exc:`!mmap.error` have been merged into :exc:`OSError`, and the
402410
constructor may return a subclass.
403411

404412
.. versionchanged:: 3.4
@@ -586,7 +594,7 @@ The following exceptions are the exceptions that are usually raised.
586594
handled, the Python interpreter exits; no stack traceback is printed. The
587595
constructor accepts the same optional argument passed to :func:`sys.exit`.
588596
If the value is an integer, it specifies the system exit status (passed to
589-
C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if
597+
C's :c:func:`!exit` function); if it is ``None``, the exit status is zero; if
590598
it has another type (such as a string), the object's value is printed and
591599
the exit status is one.
592600

_sources/library/os.path.rst.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ the :mod:`glob` module.)
298298
device than *path*, or whether :file:`{path}/..` and *path* point to the same
299299
i-node on the same device --- this should detect mount points for all Unix
300300
and POSIX variants. It is not able to reliably detect bind mounts on the
301-
same filesystem. On Windows, a drive letter root and a share UNC are
302-
always mount points, and for any other path ``GetVolumePathName`` is called
303-
to see if it is different from the input path.
301+
same filesystem. On Linux systems, it will always return ``True`` for btrfs
302+
subvolumes, even if they aren't mount points. On Windows, a drive letter root
303+
and a share UNC are always mount points, and for any other path
304+
``GetVolumePathName`` is called to see if it is different from the input path.
304305

305306
.. versionchanged:: 3.4
306307
Added support for detecting non-root mount points on Windows.

_sources/library/sqlite3.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ This section shows recipes for common adapters and converters.
23072307

23082308
def adapt_datetime_iso(val):
23092309
"""Adapt datetime.datetime to timezone-naive ISO 8601 date."""
2310-
return val.isoformat()
2310+
return val.replace(tzinfo=None).isoformat()
23112311

23122312
def adapt_datetime_epoch(val):
23132313
"""Adapt datetime.datetime to Unix timestamp."""

_sources/library/time.rst.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,11 @@ Functions
306306
.. versionadded:: 3.3
307307

308308
.. versionchanged:: 3.5
309-
The function is now always available and always system-wide.
309+
The function is now always available and the clock is now the same for
310+
all processes.
310311

311312
.. versionchanged:: 3.10
312-
On macOS, the function is now system-wide.
313+
On macOS, the clock is now the same for all processes.
313314

314315

315316
.. function:: monotonic_ns() -> int
@@ -325,7 +326,8 @@ Functions
325326

326327
Return the value (in fractional seconds) of a performance counter, i.e. a
327328
clock with the highest available resolution to measure a short duration. It
328-
does include time elapsed during sleep and is system-wide. The reference
329+
does include time elapsed during sleep. The clock is the same for all
330+
processes. The reference
329331
point of the returned value is undefined, so that only the difference between
330332
the results of two calls is valid.
331333

@@ -340,7 +342,7 @@ Functions
340342
.. versionadded:: 3.3
341343

342344
.. versionchanged:: 3.10
343-
On Windows, the function is now system-wide.
345+
On Windows, the clock is now the same for all processes.
344346

345347
.. versionchanged:: 3.13
346348
Use the same clock as :func:`time.monotonic`.
@@ -987,8 +989,8 @@ The following constant is the only parameter that can be sent to
987989

988990
.. data:: CLOCK_REALTIME
989991

990-
System-wide real-time clock. Setting this clock requires appropriate
991-
privileges.
992+
Real-time clock. Setting this clock requires appropriate privileges.
993+
The clock is the same for all processes.
992994

993995
.. availability:: Unix.
994996

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy