aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/codecs.rst6
-rw-r--r--Doc/library/email.parser.rst10
-rw-r--r--Doc/library/functools.rst33
-rw-r--r--Doc/library/math.rst26
-rw-r--r--Doc/library/platform.rst4
-rw-r--r--Doc/library/shelve.rst70
-rw-r--r--Doc/library/ssl.rst10
-rw-r--r--Doc/tools/.nitignore3
-rw-r--r--Doc/whatsnew/3.15.rst2
9 files changed, 129 insertions, 35 deletions
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index 37bd913b765..c5dae7c8e8f 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -1395,7 +1395,11 @@ encodings.
| | | It is used in the Python |
| | | pickle protocol. |
+--------------------+---------+---------------------------+
-| undefined | | Raise an exception for |
+| undefined | | This Codec should only |
+| | | be used for testing |
+| | | purposes. |
+| | | |
+| | | Raise an exception for |
| | | all conversions, even |
| | | empty strings. The error |
| | | handler is ignored. |
diff --git a/Doc/library/email.parser.rst b/Doc/library/email.parser.rst
index 439b5c8f34b..90796370ebb 100644
--- a/Doc/library/email.parser.rst
+++ b/Doc/library/email.parser.rst
@@ -48,8 +48,8 @@ methods.
FeedParser API
^^^^^^^^^^^^^^
-The :class:`BytesFeedParser`, imported from the :mod:`email.feedparser` module,
-provides an API that is conducive to incremental parsing of email messages,
+The :class:`BytesFeedParser`, imported from the :mod:`email.parser.FeedParser`
+module, provides an API that is conducive to incremental parsing of email messages,
such as would be necessary when reading the text of an email message from a
source that can block (such as a socket). The :class:`BytesFeedParser` can of
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`:
Works like :class:`BytesFeedParser` except that the input to the
:meth:`~BytesFeedParser.feed` method must be a string. This is of limited
utility, since the only way for such a message to be valid is for it to
- contain only ASCII text or, if :attr:`~email.policy.Policy.utf8` is
+ contain only ASCII text or, if :attr:`~email.policy.EmailPolicy.utf8` is
``True``, no binary attachments.
.. versionchanged:: 3.3 Added the *policy* keyword.
@@ -155,11 +155,11 @@ message body, instead setting the payload to the raw body.
Read all the data from the binary file-like object *fp*, parse the
resulting bytes, and return the message object. *fp* must support
- both the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read`
+ both the :meth:`~io.IOBase.readline` and the :meth:`~io.TextIOBase.read`
methods.
The bytes contained in *fp* must be formatted as a block of :rfc:`5322`
- (or, if :attr:`~email.policy.Policy.utf8` is ``True``, :rfc:`6532`)
+ (or, if :attr:`~email.policy.EmailPolicy.utf8` is ``True``, :rfc:`6532`)
style headers and header continuation lines, optionally preceded by an
envelope header. The header block is terminated either by the end of the
data or by a blank line. Following the header block is the body of the
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 3e75621be6d..beec9b942af 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -199,12 +199,18 @@ The :mod:`functools` module defines the following functions:
and *typed*. This is for information purposes only. Mutating the values
has no effect.
+ .. method:: lru_cache.cache_info()
+ :no-typesetting:
+
To help measure the effectiveness of the cache and tune the *maxsize*
- parameter, the wrapped function is instrumented with a :func:`cache_info`
+ parameter, the wrapped function is instrumented with a :func:`!cache_info`
function that returns a :term:`named tuple` showing *hits*, *misses*,
*maxsize* and *currsize*.
- The decorator also provides a :func:`cache_clear` function for clearing or
+ .. method:: lru_cache.cache_clear()
+ :no-typesetting:
+
+ The decorator also provides a :func:`!cache_clear` function for clearing or
invalidating the cache.
The original underlying function is accessible through the
@@ -284,9 +290,9 @@ The :mod:`functools` module defines the following functions:
class decorator supplies the rest. This simplifies the effort involved
in specifying all of the possible rich comparison operations:
- The class must define one of :meth:`__lt__`, :meth:`__le__`,
- :meth:`__gt__`, or :meth:`__ge__`.
- In addition, the class should supply an :meth:`__eq__` method.
+ The class must define one of :meth:`~object.__lt__`, :meth:`~object.__le__`,
+ :meth:`~object.__gt__`, or :meth:`~object.__ge__`.
+ In addition, the class should supply an :meth:`~object.__eq__` method.
For example::
@@ -418,7 +424,7 @@ The :mod:`functools` module defines the following functions:
like normal functions, are handled as descriptors).
When *func* is a descriptor (such as a normal Python function,
- :func:`classmethod`, :func:`staticmethod`, :func:`abstractmethod` or
+ :func:`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or
another instance of :class:`partialmethod`), calls to ``__get__`` are
delegated to the underlying descriptor, and an appropriate
:ref:`partial object<partial-objects>` returned as the result.
@@ -499,7 +505,10 @@ The :mod:`functools` module defines the following functions:
... print("Let me just say,", end=" ")
... print(arg)
- To add overloaded implementations to the function, use the :func:`register`
+ .. method:: singledispatch.register()
+ :no-typesetting:
+
+ To add overloaded implementations to the function, use the :func:`!register`
attribute of the generic function, which can be used as a decorator. For
functions annotated with types, the decorator will infer the type of the
first argument automatically::
@@ -565,14 +574,14 @@ The :mod:`functools` module defines the following functions:
runtime impact.
To enable registering :term:`lambdas<lambda>` and pre-existing functions,
- the :func:`register` attribute can also be used in a functional form::
+ the :func:`~singledispatch.register` attribute can also be used in a functional form::
>>> def nothing(arg, verbose=False):
... print("Nothing.")
...
>>> fun.register(type(None), nothing)
- The :func:`register` attribute returns the undecorated function. This
+ The :func:`~singledispatch.register` attribute returns the undecorated function. This
enables decorator stacking, :mod:`pickling<pickle>`, and the creation
of unit tests for each variant independently::
@@ -650,10 +659,10 @@ The :mod:`functools` module defines the following functions:
.. versionadded:: 3.4
.. versionchanged:: 3.7
- The :func:`register` attribute now supports using type annotations.
+ The :func:`~singledispatch.register` attribute now supports using type annotations.
.. versionchanged:: 3.11
- The :func:`register` attribute now supports
+ The :func:`~singledispatch.register` attribute now supports
:class:`typing.Union` as a type annotation.
@@ -783,7 +792,7 @@ The :mod:`functools` module defines the following functions:
'Docstring'
Without the use of this decorator factory, the name of the example function
- would have been ``'wrapper'``, and the docstring of the original :func:`example`
+ would have been ``'wrapper'``, and the docstring of the original :func:`!example`
would have been lost.
diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index bf7a00549fc..55f2de07553 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -42,6 +42,8 @@ noted otherwise, all return values are floats.
:func:`fabs(x) <fabs>` Absolute value of *x*
:func:`floor(x) <floor>` Floor of *x*, the largest integer less than or equal to *x*
:func:`fma(x, y, z) <fma>` Fused multiply-add operation: ``(x * y) + z``
+:func:`fmax(x, y) <fmax>` Maximum of two floating-point values
+:func:`fmin(x, y) <fmin>` Minimum of two floating-point values
:func:`fmod(x, y) <fmod>` Remainder of division ``x / y``
:func:`modf(x) <modf>` Fractional and integer parts of *x*
:func:`remainder(x, y) <remainder>` Remainder of *x* with respect to *y*
@@ -248,6 +250,30 @@ Floating point arithmetic
.. versionadded:: 3.13
+.. function:: fmax(x, y)
+
+ Get the larger of two floating-point values, treating NaNs as missing data.
+
+ When both operands are (signed) NaNs or zeroes, return ``nan`` and ``0``
+ respectively and the sign of the result is implementation-defined, that
+ is, :func:`!fmax` is not required to be sensitive to the sign of such
+ operands (see Annex F of the C11 standard, §F.10.0.3 and §F.10.9.2).
+
+ .. versionadded:: next
+
+
+.. function:: fmin(x, y)
+
+ Get the smaller of two floating-point values, treating NaNs as missing data.
+
+ When both operands are (signed) NaNs or zeroes, return ``nan`` and ``0``
+ respectively and the sign of the result is implementation-defined, that
+ is, :func:`!fmin` is not required to be sensitive to the sign of such
+ operands (see Annex F of the C11 standard, §F.10.0.3 and §F.10.9.3).
+
+ .. versionadded:: next
+
+
.. function:: fmod(x, y)
Return the floating-point remainder of ``x / y``,
diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst
index 06de152a742..37df13f8a1e 100644
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -176,8 +176,8 @@ Cross platform
:attr:`processor` is resolved late, on demand.
Note: the first two attribute names differ from the names presented by
- :func:`os.uname`, where they are named :attr:`sysname` and
- :attr:`nodename`.
+ :func:`os.uname`, where they are named :attr:`!sysname` and
+ :attr:`!nodename`.
Entries which cannot be determined are set to ``''``.
diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst
index 23a2e0c3d0c..23808619524 100644
--- a/Doc/library/shelve.rst
+++ b/Doc/library/shelve.rst
@@ -17,7 +17,8 @@ This includes most class instances, recursive data types, and objects containing
lots of shared sub-objects. The keys are ordinary strings.
-.. function:: open(filename, flag='c', protocol=None, writeback=False)
+.. function:: open(filename, flag='c', protocol=None, writeback=False, *, \
+ serializer=None, deserializer=None)
Open a persistent dictionary. The filename specified is the base filename for
the underlying database. As a side-effect, an extension may be added to the
@@ -41,6 +42,21 @@ lots of shared sub-objects. The keys are ordinary strings.
determine which accessed entries are mutable, nor which ones were actually
mutated).
+ By default, :mod:`shelve` uses :func:`pickle.dumps` and :func:`pickle.loads`
+ for serializing and deserializing. This can be changed by supplying
+ *serializer* and *deserializer*, respectively.
+
+ The *serializer* argument must be a callable which takes an object ``obj``
+ and the *protocol* as inputs and returns the representation ``obj`` as a
+ :term:`bytes-like object`; the *protocol* value may be ignored by the
+ serializer.
+
+ The *deserializer* argument must be callable which takes a serialized object
+ given as a :class:`bytes` object and returns the corresponding object.
+
+ A :exc:`ShelveError` is raised if *serializer* is given but *deserializer*
+ is not, or vice-versa.
+
.. versionchanged:: 3.10
:const:`pickle.DEFAULT_PROTOCOL` is now used as the default pickle
protocol.
@@ -48,6 +64,10 @@ lots of shared sub-objects. The keys are ordinary strings.
.. versionchanged:: 3.11
Accepts :term:`path-like object` for filename.
+ .. versionchanged:: next
+ Accepts custom *serializer* and *deserializer* functions in place of
+ :func:`pickle.dumps` and :func:`pickle.loads`.
+
.. note::
Do not rely on the shelf being closed automatically; always call
@@ -129,7 +149,8 @@ Restrictions
explicitly.
-.. class:: Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8')
+.. class:: Shelf(dict, protocol=None, writeback=False, \
+ keyencoding='utf-8', *, serializer=None, deserializer=None)
A subclass of :class:`collections.abc.MutableMapping` which stores pickled
values in the *dict* object.
@@ -147,6 +168,9 @@ Restrictions
The *keyencoding* parameter is the encoding used to encode keys before they
are used with the underlying dict.
+ The *serializer* and *deserializer* parameters have the same interpretation
+ as in :func:`~shelve.open`.
+
A :class:`Shelf` object can also be used as a context manager, in which
case it will be automatically closed when the :keyword:`with` block ends.
@@ -161,8 +185,13 @@ Restrictions
:const:`pickle.DEFAULT_PROTOCOL` is now used as the default pickle
protocol.
+ .. versionchanged:: next
+ Added the *serializer* and *deserializer* parameters.
-.. class:: BsdDbShelf(dict, protocol=None, writeback=False, keyencoding='utf-8')
+
+.. class:: BsdDbShelf(dict, protocol=None, writeback=False, \
+ keyencoding='utf-8', *, \
+ serializer=None, deserializer=None)
A subclass of :class:`Shelf` which exposes :meth:`!first`, :meth:`!next`,
:meth:`!previous`, :meth:`!last` and :meth:`!set_location` methods.
@@ -172,18 +201,27 @@ Restrictions
modules. The *dict* object passed to the constructor must support those
methods. This is generally accomplished by calling one of
:func:`!bsddb.hashopen`, :func:`!bsddb.btopen` or :func:`!bsddb.rnopen`. The
- optional *protocol*, *writeback*, and *keyencoding* parameters have the same
- interpretation as for the :class:`Shelf` class.
+ optional *protocol*, *writeback*, *keyencoding*, *serializer* and *deserializer*
+ parameters have the same interpretation as in :func:`~shelve.open`.
+
+ .. versionchanged:: next
+ Added the *serializer* and *deserializer* parameters.
-.. class:: DbfilenameShelf(filename, flag='c', protocol=None, writeback=False)
+.. class:: DbfilenameShelf(filename, flag='c', protocol=None, \
+ writeback=False, *, serializer=None, \
+ deserializer=None)
A subclass of :class:`Shelf` which accepts a *filename* instead of a dict-like
object. The underlying file will be opened using :func:`dbm.open`. By
default, the file will be created and opened for both read and write. The
- optional *flag* parameter has the same interpretation as for the :func:`.open`
- function. The optional *protocol* and *writeback* parameters have the same
- interpretation as for the :class:`Shelf` class.
+ optional *flag* parameter has the same interpretation as for the
+ :func:`.open` function. The optional *protocol*, *writeback*, *serializer*
+ and *deserializer* parameters have the same interpretation as in
+ :func:`~shelve.open`.
+
+ .. versionchanged:: next
+ Added the *serializer* and *deserializer* parameters.
.. _shelve-example:
@@ -225,6 +263,20 @@ object)::
d.close() # close it
+Exceptions
+----------
+
+.. exception:: ShelveError
+
+ Exception raised when one of the arguments *deserializer* and *serializer*
+ is missing in the :func:`~shelve.open`, :class:`Shelf`, :class:`BsdDbShelf`
+ and :class:`DbfilenameShelf`.
+
+ The *deserializer* and *serializer* arguments must be given together.
+
+ .. versionadded:: next
+
+
.. seealso::
Module :mod:`dbm`
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index ae2e324d0ab..a9930183f9a 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -1078,8 +1078,9 @@ SSL Sockets
(but passing a non-zero ``flags`` argument is not allowed)
- :meth:`~socket.socket.send`, :meth:`~socket.socket.sendall` (with
the same limitation)
- - :meth:`~socket.socket.sendfile` (but :mod:`os.sendfile` will be used
- for plain-text sockets only, else :meth:`~socket.socket.send` will be used)
+ - :meth:`~socket.socket.sendfile` (it may be high-performant only when
+ the kernel TLS is enabled by setting :data:`~ssl.OP_ENABLE_KTLS` or when a
+ socket is plain-text, else :meth:`~socket.socket.send` will be used)
- :meth:`~socket.socket.shutdown`
However, since the SSL (and TLS) protocol has its own framing atop
@@ -1113,6 +1114,11 @@ SSL Sockets
functions support reading and writing of data larger than 2 GB. Writing
zero-length data no longer fails with a protocol violation error.
+ .. versionchanged:: next
+ Python now uses ``SSL_sendfile`` internally when possible. The
+ function sends a file more efficiently because it performs TLS encryption
+ in the kernel to avoid additional context switches.
+
SSL sockets also have the following additional methods and attributes:
.. method:: SSLSocket.read(len=1024, buffer=None)
diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore
index 4f5396857f3..510225afab8 100644
--- a/Doc/tools/.nitignore
+++ b/Doc/tools/.nitignore
@@ -15,8 +15,6 @@ Doc/extending/extending.rst
Doc/library/ast.rst
Doc/library/asyncio-extending.rst
Doc/library/email.charset.rst
-Doc/library/email.parser.rst
-Doc/library/functools.rst
Doc/library/http.cookiejar.rst
Doc/library/http.server.rst
Doc/library/importlib.rst
@@ -28,7 +26,6 @@ Doc/library/multiprocessing.rst
Doc/library/optparse.rst
Doc/library/os.rst
Doc/library/pickletools.rst
-Doc/library/platform.rst
Doc/library/profile.rst
Doc/library/pyexpat.rst
Doc/library/resource.rst
diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst
index e9b88458acd..010abb7d9b9 100644
--- a/Doc/whatsnew/3.15.rst
+++ b/Doc/whatsnew/3.15.rst
@@ -212,7 +212,7 @@ math
* Add :func:`math.isnormal` and :func:`math.issubnormal` functions.
(Contributed by Sergey B Kirpichev in :gh:`132908`.)
-* Add :func:`math.signbit` function.
+* Add :func:`math.fmax`, :func:`math.fmin` and :func:`math.signbit` functions.
(Contributed by Bénédikt Tran in :gh:`135853`.)