Skip to content

Commit a462d41

Browse files
Merge branch 'main' into test-socket-bluetooth2
2 parents 9fd55c7 + bfc292a commit a462d41

File tree

88 files changed

+9034
-626
lines changed

Some content is hidden

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

88 files changed

+9034
-626
lines changed

Doc/library/annotationlib.rst

-6
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ Classes
204204
means may not have any information about their scope, so passing
205205
arguments to this method may be necessary to evaluate them successfully.
206206

207-
.. important::
208-
209-
Once a :class:`~ForwardRef` instance has been evaluated, it caches
210-
the evaluated value, and future calls to :meth:`evaluate` will return
211-
the cached value, regardless of the parameters passed in.
212-
213207
.. versionadded:: 3.14
214208

215209

Doc/library/http.server.rst

+72-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,49 @@ handler. Code to create and run the server looks like this::
5151
.. versionadded:: 3.7
5252

5353

54-
The :class:`HTTPServer` and :class:`ThreadingHTTPServer` must be given
55-
a *RequestHandlerClass* on instantiation, of which this module
56-
provides three different variants:
54+
.. class:: HTTPSServer(server_address, RequestHandlerClass,\
55+
bind_and_activate=True, *, certfile, keyfile=None,\
56+
password=None, alpn_protocols=None)
57+
58+
Subclass of :class:`HTTPServer` with a wrapped socket using the :mod:`ssl` module.
59+
If the :mod:`ssl` module is not available, instantiating a :class:`!HTTPSServer`
60+
object fails with a :exc:`RuntimeError`.
61+
62+
The *certfile* argument is the path to the SSL certificate chain file,
63+
and the *keyfile* is the path to file containing the private key.
64+
65+
A *password* can be specified for files protected and wrapped with PKCS#8,
66+
but beware that this could possibly expose hardcoded passwords in clear.
67+
68+
.. seealso::
69+
70+
See :meth:`ssl.SSLContext.load_cert_chain` for additional
71+
information on the accepted values for *certfile*, *keyfile*
72+
and *password*.
73+
74+
When specified, the *alpn_protocols* argument must be a sequence of strings
75+
specifying the "Application-Layer Protocol Negotiation" (ALPN) protocols
76+
supported by the server. ALPN allows the server and the client to negotiate
77+
the application protocol during the TLS handshake.
78+
79+
By default, it is set to ``["http/1.1"]``, meaning the server supports HTTP/1.1.
80+
81+
.. versionadded:: next
82+
83+
.. class:: ThreadingHTTPSServer(server_address, RequestHandlerClass,\
84+
bind_and_activate=True, *, certfile, keyfile=None,\
85+
password=None, alpn_protocols=None)
86+
87+
This class is identical to :class:`HTTPSServer` but uses threads to handle
88+
requests by inheriting from :class:`~socketserver.ThreadingMixIn`. This is
89+
analogous to :class:`ThreadingHTTPServer` only using :class:`HTTPSServer`.
90+
91+
.. versionadded:: next
92+
93+
94+
The :class:`HTTPServer`, :class:`ThreadingHTTPServer`, :class:`HTTPSServer` and
95+
:class:`ThreadingHTTPSServer` must be given a *RequestHandlerClass* on
96+
instantiation, of which this module provides three different variants:
5797

5898
.. class:: BaseHTTPRequestHandler(request, client_address, server)
5999

@@ -542,6 +582,35 @@ The following options are accepted:
542582
are not intended for use by untrusted clients and may be vulnerable
543583
to exploitation. Always use within a secure environment.
544584

585+
.. option:: --tls-cert
586+
587+
Specifies a TLS certificate chain for HTTPS connections::
588+
589+
python -m http.server --tls-cert fullchain.pem
590+
591+
.. versionadded:: next
592+
593+
.. option:: --tls-key
594+
595+
Specifies a private key file for HTTPS connections.
596+
597+
This option requires ``--tls-cert`` to be specified.
598+
599+
.. versionadded:: next
600+
601+
.. option:: --tls-password-file
602+
603+
Specifies the password file for password-protected private keys::
604+
605+
python -m http.server \
606+
--tls-cert cert.pem \
607+
--tls-key key.pem \
608+
--tls-password-file password.txt
609+
610+
This option requires `--tls-cert`` to be specified.
611+
612+
.. versionadded:: next
613+
545614

546615
.. _http.server-security:
547616

Doc/library/plistlib.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ This module defines the following functions:
7878
exceptions on ill-formed XML. Unknown elements will simply be ignored
7979
by the plist parser.
8080

81-
The parser for the binary format raises :exc:`InvalidFileException`
82-
when the file cannot be parsed.
81+
The parser raises :exc:`InvalidFileException` when the file cannot be parsed.
8382

8483
.. versionadded:: 3.4
8584

@@ -170,6 +169,15 @@ The following constants are available:
170169
.. versionadded:: 3.4
171170

172171

172+
The module defines the following exceptions:
173+
174+
.. exception:: InvalidFileException
175+
176+
Raised when a file cannot be parsed.
177+
178+
.. versionadded:: 3.4
179+
180+
173181
Examples
174182
--------
175183

Doc/library/string.rst

+50-37
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ The general form of a *standard format specifier* is:
325325
align: "<" | ">" | "=" | "^"
326326
sign: "+" | "-" | " "
327327
width_and_precision: [`width_with_grouping`][`precision_with_grouping`]
328-
width_with_grouping: [`width`][`grouping_option`]
329-
precision_with_grouping: "." [`precision`]`grouping_option`
328+
width_with_grouping: [`width`][`grouping`]
329+
precision_with_grouping: "." [`precision`][`grouping`]
330330
width: `~python-grammar:digit`+
331-
grouping_option: "_" | ","
332331
precision: `~python-grammar:digit`+
332+
grouping: "," | "_"
333333
type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g"
334334
: | "G" | "n" | "o" | "s" | "x" | "X" | "%"
335335

@@ -385,13 +385,13 @@ following:
385385
+---------+----------------------------------------------------------+
386386
| Option | Meaning |
387387
+=========+==========================================================+
388-
| ``'+'`` | indicates that a sign should be used for both |
388+
| ``'+'`` | Indicates that a sign should be used for both |
389389
| | positive as well as negative numbers. |
390390
+---------+----------------------------------------------------------+
391-
| ``'-'`` | indicates that a sign should be used only for negative |
391+
| ``'-'`` | Indicates that a sign should be used only for negative |
392392
| | numbers (this is the default behavior). |
393393
+---------+----------------------------------------------------------+
394-
| space | indicates that a leading space should be used on |
394+
| space | Indicates that a leading space should be used on |
395395
| | positive numbers, and a minus sign on negative numbers. |
396396
+---------+----------------------------------------------------------+
397397

@@ -419,30 +419,7 @@ decimal-point character appears in the result of these conversions
419419
only if a digit follows it. In addition, for ``'g'`` and ``'G'``
420420
conversions, trailing zeros are not removed from the result.
421421

422-
.. index:: single: , (comma); in string formatting
423-
424-
The ``','`` option signals the use of a comma for a thousands separator for
425-
floating-point presentation types and for integer presentation type ``'d'``.
426-
For other presentation types, this option is an error.
427-
For a locale aware separator, use the ``'n'`` integer presentation type
428-
instead.
429-
430-
.. versionchanged:: 3.1
431-
Added the ``','`` option (see also :pep:`378`).
432-
433-
.. index:: single: _ (underscore); in string formatting
434-
435-
The ``'_'`` option signals the use of an underscore for a thousands
436-
separator for floating-point presentation types and for integer
437-
presentation type ``'d'``. For integer presentation types ``'b'``,
438-
``'o'``, ``'x'``, and ``'X'``, underscores will be inserted every 4
439-
digits. For other presentation types, specifying this option is an
440-
error.
441-
442-
.. versionchanged:: 3.6
443-
Added the ``'_'`` option (see also :pep:`515`).
444-
445-
*width* is a decimal integer defining the minimum total field width,
422+
The *width* is a decimal integer defining the minimum total field width,
446423
including any prefixes, separators, and other formatting characters.
447424
If not specified, then the field width will be determined by the content.
448425

@@ -463,12 +440,43 @@ indicates the maximum field size - in other words, how many characters will be
463440
used from the field content. The *precision* is not allowed for integer
464441
presentation types.
465442

466-
The ``'_'`` or ``','`` option after *precision* means the use of an underscore
467-
or a comma for a thousands separator of the fractional part for floating-point
468-
presentation types.
443+
The *grouping* option after *width* and *precision* fields specifies
444+
a digit group separator for the integral and fractional parts
445+
of a number respectively. It can be one of the following:
446+
447+
.. index::
448+
single: , (comma); in string formatting
449+
single: _ (underscore); in string formatting
450+
451+
+---------+----------------------------------------------------------+
452+
| Option | Meaning |
453+
+=========+==========================================================+
454+
| ``','`` | Inserts a comma every 3 digits for |
455+
| | integer presentation type ``'d'`` and |
456+
| | floating-point presentation types, excluding ``'n'``. |
457+
| | For other presentation types, |
458+
| | this option is not supported. |
459+
+---------+----------------------------------------------------------+
460+
| ``'_'`` | Inserts an underscore every 3 digits for |
461+
| | integer presentation type ``'d'`` and |
462+
| | floating-point presentation types, excluding ``'n'``. |
463+
| | For integer presentation types |
464+
| | ``'b'``, ``'o'``, ``'x'``, and ``'X'``, |
465+
| | underscores are inserted every 4 digits. |
466+
| | For other presentation types, |
467+
| | this option is not supported. |
468+
+---------+----------------------------------------------------------+
469+
470+
For a locale aware separator, use the ``'n'`` presentation type instead.
471+
472+
.. versionchanged:: 3.1
473+
Added the ``','`` option (see also :pep:`378`).
474+
475+
.. versionchanged:: 3.6
476+
Added the ``'_'`` option (see also :pep:`515`).
469477

470478
.. versionchanged:: 3.14
471-
Support thousands separators for the fractional part.
479+
Support the *grouping* option for the fractional part.
472480

473481
Finally, the *type* determines how the data should be presented.
474482

@@ -507,7 +515,7 @@ The available integer presentation types are:
507515
+---------+----------------------------------------------------------+
508516
| ``'n'`` | Number. This is the same as ``'d'``, except that it uses |
509517
| | the current locale setting to insert the appropriate |
510-
| | number separator characters. |
518+
| | digit group separators. |
511519
+---------+----------------------------------------------------------+
512520
| None | The same as ``'d'``. |
513521
+---------+----------------------------------------------------------+
@@ -589,7 +597,8 @@ The available presentation types for :class:`float` and
589597
+---------+----------------------------------------------------------+
590598
| ``'n'`` | Number. This is the same as ``'g'``, except that it uses |
591599
| | the current locale setting to insert the appropriate |
592-
| | number separator characters. |
600+
| | digit group separators |
601+
| | for the integral part of a number. |
593602
+---------+----------------------------------------------------------+
594603
| ``'%'`` | Percentage. Multiplies the number by 100 and displays |
595604
| | in fixed (``'f'``) format, followed by a percent sign. |
@@ -716,12 +725,16 @@ Replacing ``%x`` and ``%o`` and converting the value to different bases::
716725
>>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)
717726
'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'
718727

719-
Using the comma or the underscore as a thousands separator::
728+
Using the comma or the underscore as a digit group separator::
720729

721730
>>> '{:,}'.format(1234567890)
722731
'1,234,567,890'
723732
>>> '{:_}'.format(1234567890)
724733
'1_234_567_890'
734+
>>> '{:_b}'.format(1234567890)
735+
'100_1001_1001_0110_0000_0010_1101_0010'
736+
>>> '{:_x}'.format(1234567890)
737+
'4996_02d2'
725738
>>> '{:_}'.format(123456789.123456789)
726739
'123_456_789.12345679'
727740
>>> '{:._}'.format(123456789.123456789)

Doc/library/typing.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -3449,7 +3449,9 @@ Introspection helpers
34493449
.. versionadded:: 3.7.4
34503450

34513451
.. versionchanged:: 3.14
3452-
This is now an alias for :class:`annotationlib.ForwardRef`.
3452+
This is now an alias for :class:`annotationlib.ForwardRef`. Several undocumented
3453+
behaviors of this class have been changed; for example, after a ``ForwardRef`` has
3454+
been evaluated, the evaluated value is no longer cached.
34533455

34543456
.. function:: evaluate_forward_ref(forward_ref, *, owner=None, globals=None, locals=None, type_params=None, format=annotationlib.Format.VALUE)
34553457

0 commit comments

Comments
 (0)