Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 82fe16c

Browse filesBrowse files
committed
Merge branch 'main' into pep-669
2 parents c6bf38e + a44568b commit 82fe16c
Copy full SHA for 82fe16c

File tree

Expand file treeCollapse file tree

158 files changed

+3367
-2002
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

158 files changed

+3367
-2002
lines changed

‎.devcontainer/devcontainer.json

Copy file name to clipboardExpand all lines: .devcontainer/devcontainer.json
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@
3737
// "ms-python.python"
3838
],
3939
"settings": {
40+
"C_Cpp.default.compilerPath": "/usr/bin/clang",
4041
"C_Cpp.default.cStandard": "c11",
4142
"C_Cpp.default.defines": [
43+
"CONFIG_64",
4244
"Py_BUILD_CORE"
4345
],
46+
"C_Cpp.default.includePath": [
47+
"${workspaceFolder}/*",
48+
"${workspaceFolder}/Include/**"
49+
],
4450
// https://github.com/microsoft/vscode-cpptools/issues/10732
4551
"C_Cpp.errorSquiggles": "disabled",
4652
"editor.insertSpaces": true,

‎Doc/howto/enum.rst

Copy file name to clipboardExpand all lines: Doc/howto/enum.rst
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ The values are chosen by :func:`_generate_next_value_`, which can be
284284
overridden::
285285

286286
>>> class AutoName(Enum):
287+
... @staticmethod
287288
... def _generate_next_value_(name, start, count, last_values):
288289
... return name
289290
...
@@ -372,6 +373,11 @@ below)::
372373
>>> Color.BLUE == 2
373374
False
374375

376+
.. warning::
377+
378+
It is possible to reload modules -- if a reloaded module contains
379+
enums, they will be recreated, and the new members may not
380+
compare identical/equal to the original members.
375381

376382
Allowed members and attributes of enumerations
377383
----------------------------------------------
@@ -982,12 +988,11 @@ but remain normal attributes.
982988
""""""""""""""""""""
983989

984990
Enum members are instances of their enum class, and are normally accessed as
985-
``EnumClass.member``. In Python versions starting with ``3.5`` you could access
986-
members from other members -- this practice is discouraged, is deprecated
987-
in ``3.12``, and will be removed in ``3.14``.
991+
``EnumClass.member``. In certain situations, such as writing custom enum
992+
behavior, being able to access one member directly from another is useful,
993+
and is supported.
988994

989995
.. versionchanged:: 3.5
990-
.. versionchanged:: 3.12
991996

992997

993998
Creating members that are mixed with other data types

‎Doc/library/dis.rst

Copy file name to clipboardExpand all lines: Doc/library/dis.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ the following command can be used to display the disassembly of
5959
3 2 LOAD_GLOBAL 1 (NULL + len)
6060
12 LOAD_FAST 0 (alist)
6161
14 CALL 1
62-
24 RETURN_VALUE
62+
22 RETURN_VALUE
6363

6464
(The "2" is a line number).
6565

‎Doc/library/enum.rst

Copy file name to clipboardExpand all lines: Doc/library/enum.rst
+25-26Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ Module Contents
141141
:func:`global_enum`
142142

143143
Modify the :class:`str() <str>` and :func:`repr` of an enum
144-
to show its members as belonging to the module instead of its class.
145-
Should only be used if the enum members will be exported to the
146-
module global namespace.
144+
to show its members as belonging to the module instead of its class,
145+
and export the enum members to the global namespace.
147146

148147
:func:`show_flag_values`
149148

@@ -170,6 +169,27 @@ Data Types
170169
final *enum*, as well as creating the enum members, properly handling
171170
duplicates, providing iteration over the enum class, etc.
172171

172+
.. method:: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
173+
174+
This method is called in two different ways:
175+
176+
* to look up an existing member:
177+
178+
:cls: The enum class being called.
179+
:value: The value to lookup.
180+
181+
* to use the ``cls`` enum to create a new enum (only if the existing enum
182+
does not have any members):
183+
184+
:cls: The enum class being called.
185+
:value: The name of the new Enum to create.
186+
:names: The names/values of the members for the new Enum.
187+
:module: The name of the module the new Enum is created in.
188+
:qualname: The actual location in the module where this Enum can be found.
189+
:type: A mix-in type for the new Enum.
190+
:start: The first integer value for the Enum (used by :class:`auto`).
191+
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
192+
173193
.. method:: EnumType.__contains__(cls, member)
174194

175195
Returns ``True`` if member belongs to the ``cls``::
@@ -255,26 +275,6 @@ Data Types
255275
names will also be removed from the completed enumeration. See
256276
:ref:`TimePeriod <enum-time-period>` for an example.
257277

258-
.. method:: Enum.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
259-
260-
This method is called in two different ways:
261-
262-
* to look up an existing member:
263-
264-
:cls: The enum class being called.
265-
:value: The value to lookup.
266-
267-
* to use the ``cls`` enum to create a new enum:
268-
269-
:cls: The enum class being called.
270-
:value: The name of the new Enum to create.
271-
:names: The names/values of the members for the new Enum.
272-
:module: The name of the module the new Enum is created in.
273-
:qualname: The actual location in the module where this Enum can be found.
274-
:type: A mix-in type for the new Enum.
275-
:start: The first integer value for the Enum (used by :class:`auto`).
276-
:boundary: How to handle out-of-range values from bit operations (:class:`Flag` only).
277-
278278
.. method:: Enum.__dir__(self)
279279

280280
Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and
@@ -728,7 +728,6 @@ Data Types
728728
.. attribute:: EJECT
729729

730730
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
731-
This is the default for :class:`IntFlag`::
732731

733732
>>> from enum import Flag, EJECT, auto
734733
>>> class EjectFlag(Flag, boundary=EJECT):
@@ -741,8 +740,8 @@ Data Types
741740

742741
.. attribute:: KEEP
743742

744-
Out-of-range values are kept, and the *Flag* membership is kept. This is
745-
used for some stdlib flags::
743+
Out-of-range values are kept, and the *Flag* membership is kept.
744+
This is the default for :class:`IntFlag`::
746745

747746
>>> from enum import Flag, KEEP, auto
748747
>>> class KeepFlag(Flag, boundary=KEEP):

‎Doc/library/functions.rst

Copy file name to clipboardExpand all lines: Doc/library/functions.rst
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,9 @@ are always available. They are listed here in alphabetical order.
14441444
arguments are converted to text strings, :func:`print` cannot be used with
14451445
binary mode file objects. For these, use ``file.write(...)`` instead.
14461446

1447-
Whether the output is buffered is usually determined by *file*, but if the
1448-
*flush* keyword argument is true, the stream is forcibly flushed.
1447+
Output buffering is usually determined by *file*.
1448+
However, if *flush* is true, the stream is forcibly flushed.
1449+
14491450

14501451
.. versionchanged:: 3.3
14511452
Added the *flush* keyword argument.

‎Doc/library/http.client.rst

Copy file name to clipboardExpand all lines: Doc/library/http.client.rst
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,13 @@ HTTPConnection Objects
353353
The *headers* argument should be a mapping of extra HTTP headers to send with
354354
the CONNECT request.
355355

356+
As HTTP/1.1 is used for HTTP CONNECT tunnelling request, `as per the RFC
357+
<https://tools.ietf.org/html/rfc7231#section-4.3.6>`_, a HTTP ``Host:``
358+
header must be provided, matching the authority-form of the request target
359+
provided as the destination for the CONNECT request. If a HTTP ``Host:``
360+
header is not provided via the headers argument, one is generated and
361+
transmitted automatically.
362+
356363
For example, to tunnel through a HTTPS proxy server running locally on port
357364
8080, we would pass the address of the proxy to the :class:`HTTPSConnection`
358365
constructor, and the address of the host that we eventually want to reach to
@@ -365,6 +372,11 @@ HTTPConnection Objects
365372

366373
.. versionadded:: 3.2
367374

375+
.. versionchanged:: 3.12
376+
HTTP CONNECT tunnelling requests use protocol HTTP/1.1, upgraded from
377+
protocol HTTP/1.0. ``Host:`` HTTP headers are mandatory for HTTP/1.1, so
378+
one will be automatically generated and transmitted if not provided in
379+
the headers argument.
368380

369381
.. method:: HTTPConnection.connect()
370382

‎Doc/library/multiprocessing.rst

Copy file name to clipboardExpand all lines: Doc/library/multiprocessing.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,16 @@ process which created it.
460460
... return x*x
461461
...
462462
>>> with p:
463-
... p.map(f, [1,2,3])
463+
... p.map(f, [1,2,3])
464464
Process PoolWorker-1:
465465
Process PoolWorker-2:
466466
Process PoolWorker-3:
467467
Traceback (most recent call last):
468468
Traceback (most recent call last):
469469
Traceback (most recent call last):
470-
AttributeError: 'module' object has no attribute 'f'
471-
AttributeError: 'module' object has no attribute 'f'
472-
AttributeError: 'module' object has no attribute 'f'
470+
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
471+
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
472+
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
473473

474474
(If you try this it will actually output three full tracebacks
475475
interleaved in a semi-random fashion, and then you may have to

‎Doc/library/shutil.rst

Copy file name to clipboardExpand all lines: Doc/library/shutil.rst
+27-7Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,23 +433,43 @@ Directory and files operations
433433
When no *path* is specified, the results of :func:`os.environ` are used,
434434
returning either the "PATH" value or a fallback of :attr:`os.defpath`.
435435

436-
On Windows, the current directory is always prepended to the *path* whether
437-
or not you use the default or provide your own, which is the behavior the
438-
command shell uses when finding executables. Additionally, when finding the
439-
*cmd* in the *path*, the ``PATHEXT`` environment variable is checked. For
440-
example, if you call ``shutil.which("python")``, :func:`which` will search
441-
``PATHEXT`` to know that it should look for ``python.exe`` within the *path*
442-
directories. For example, on Windows::
436+
On Windows, the current directory is prepended to the *path* if *mode* does
437+
not include ``os.X_OK``. When the *mode* does include ``os.X_OK``, the
438+
Windows API ``NeedCurrentDirectoryForExePathW`` will be consulted to
439+
determine if the current directory should be prepended to *path*. To avoid
440+
consulting the current working directory for executables: set the environment
441+
variable ``NoDefaultCurrentDirectoryInExePath``.
442+
443+
Also on Windows, the ``PATHEXT`` variable is used to resolve commands
444+
that may not already include an extension. For example, if you call
445+
``shutil.which("python")``, :func:`which` will search ``PATHEXT``
446+
to know that it should look for ``python.exe`` within the *path*
447+
directories. For example, on Windows::
443448

444449
>>> shutil.which("python")
445450
'C:\\Python33\\python.EXE'
446451

452+
This is also applied when *cmd* is a path that contains a directory
453+
component::
454+
455+
>> shutil.which("C:\\Python33\\python")
456+
'C:\\Python33\\python.EXE'
457+
447458
.. versionadded:: 3.3
448459

449460
.. versionchanged:: 3.8
450461
The :class:`bytes` type is now accepted. If *cmd* type is
451462
:class:`bytes`, the result type is also :class:`bytes`.
452463

464+
.. versionchanged:: 3.12
465+
On Windows, the current directory is no longer prepended to the search
466+
path if *mode* includes ``os.X_OK`` and WinAPI
467+
``NeedCurrentDirectoryForExePathW(cmd)`` is false, else the current
468+
directory is prepended even if it is already in the search path;
469+
``PATHEXT`` is used now even when *cmd* includes a directory component
470+
or ends with an extension that is in ``PATHEXT``; and filenames that
471+
have no extension can now be found.
472+
453473
.. exception:: Error
454474

455475
This exception collects exceptions that are raised during a multi-file

‎Doc/library/socket.rst

Copy file name to clipboardExpand all lines: Doc/library/socket.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ to sockets.
17751775
much data, if any, was successfully sent.
17761776

17771777
.. versionchanged:: 3.5
1778-
The socket timeout is no more reset each time data is sent successfully.
1778+
The socket timeout is no longer reset each time data is sent successfully.
17791779
The socket timeout is now the maximum total duration to send all data.
17801780

17811781
.. versionchanged:: 3.5
@@ -1998,8 +1998,8 @@ can be changed by calling :func:`setdefaulttimeout`.
19981998

19991999
* In *non-blocking mode*, operations fail (with an error that is unfortunately
20002000
system-dependent) if they cannot be completed immediately: functions from the
2001-
:mod:`select` can be used to know when and whether a socket is available for
2002-
reading or writing.
2001+
:mod:`select` module can be used to know when and whether a socket is available
2002+
for reading or writing.
20032003

20042004
* In *timeout mode*, operations fail if they cannot be completed within the
20052005
timeout specified for the socket (they raise a :exc:`timeout` exception)
@@ -2188,7 +2188,7 @@ manager protocol instead, open a socket with::
21882188
socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM)
21892189

21902190
After binding (:const:`CAN_RAW`) or connecting (:const:`CAN_BCM`) the socket, you
2191-
can use the :meth:`socket.send`, and the :meth:`socket.recv` operations (and
2191+
can use the :meth:`socket.send` and :meth:`socket.recv` operations (and
21922192
their counterparts) on the socket object as usual.
21932193

21942194
This last example might require special privileges::

‎Doc/library/sys.rst

Copy file name to clipboardExpand all lines: Doc/library/sys.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ always available.
697697
the encoding used with the :term:`filesystem error handler <filesystem
698698
encoding and error handler>` to convert between Unicode filenames and bytes
699699
filenames. The filesystem error handler is returned from
700-
:func:`getfilesystemencoding`.
700+
:func:`getfilesystemencodeerrors`.
701701

702702
For best compatibility, str should be used for filenames in all cases,
703703
although representing filenames as bytes is also supported. Functions

‎Doc/reference/datamodel.rst

Copy file name to clipboardExpand all lines: Doc/reference/datamodel.rst
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,8 @@ Internal types
991991
the filename from which the code was compiled; :attr:`co_firstlineno` is
992992
the first line number of the function; :attr:`co_lnotab` is a string
993993
encoding the mapping from bytecode offsets to line numbers (for details
994-
see the source code of the interpreter); :attr:`co_stacksize` is the
994+
see the source code of the interpreter, is deprecated since 3.12
995+
and may be removed in 3.14); :attr:`co_stacksize` is the
995996
required stack size; :attr:`co_flags` is an integer encoding a number
996997
of flags for the interpreter.
997998

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.