FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge branch 'main' into issue-86298 · python/cpython@06d686d · GitHub

/ cpython Public

Commit 06d686d

Browse files
authored
Merge branch 'main' into issue-86298
2 parents 428d863 + 9fbfa42 commit 06d686d

76 files changed

Lines changed: 300 additions & 7484 deletions

Some content is hidden

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

‎.github/workflows/project-updater.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- { project: 2, label: "release-blocker, deferred-blocker" }
1919
- { project: 3, label: expert-subinterpreters }
2020
- { project: 29, label: expert-asyncio }
21+
- { project: 32, label: sprint }
2122

2223
steps:
2324
- uses: actions/add-to-project@v0.1.0

‎Doc/c-api/exceptions.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ For convenience, some of these functions will always return a
189189
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
190190
191191
This is a convenience function to raise :exc:`WindowsError`. If called with
192-
*ierr* of :c:data:`0`, the error code returned by a call to :c:func:`GetLastError`
192+
*ierr* of ``0``, the error code returned by a call to :c:func:`GetLastError`
193193
is used instead. It calls the Win32 function :c:func:`FormatMessage` to retrieve
194194
the Windows description of error code given by *ierr* or :c:func:`GetLastError`,
195195
then it constructs a tuple object whose first item is the *ierr* value and whose

‎Doc/faq/programming.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ Is it possible to write obfuscated one-liners in Python?
735735
--------------------------------------------------------
736736

737737
Yes. Usually this is done by nesting :keyword:`lambda` within
738-
:keyword:`!lambda`. See the following three examples, due to Ulf Bartelt::
738+
:keyword:`!lambda`. See the following three examples, slightly adapted from Ulf Bartelt::
739739

740740
from functools import reduce
741741

@@ -748,7 +748,7 @@ Yes. Usually this is done by nesting :keyword:`lambda` within
748748
f(x,f), range(10))))
749749

750750
# Mandelbrot set
751-
print((lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
751+
print((lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+'\n'+y,map(lambda y,
752752
Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
753753
Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
754754
i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y

‎Doc/library/asyncio-eventloop.rst‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,9 +1632,12 @@ on Unix and :class:`ProactorEventLoop` on Windows.
16321632
import asyncio
16331633
import selectors
16341634

1635-
selector = selectors.SelectSelector()
1636-
loop = asyncio.SelectorEventLoop(selector)
1637-
asyncio.set_event_loop(loop)
1635+
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1636+
def new_event_loop(self):
1637+
selector = selectors.SelectSelector()
1638+
return asyncio.SelectorEventLoop(selector)
1639+
1640+
asyncio.set_event_loop_policy(MyPolicy())
16381641

16391642

16401643
.. availability:: Unix, Windows.

‎Doc/library/http.client.rst‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
--------------
1616

17-
This module defines classes which implement the client side of the HTTP and
17+
This module defines classes that implement the client side of the HTTP and
1818
HTTPS protocols. It is normally not used directly --- the module
1919
:mod:`urllib.request` uses it to handle URLs that use HTTP and HTTPS.
2020

@@ -37,7 +37,7 @@ The module provides the following classes:
3737
blocksize=8192)
3838

3939
An :class:`HTTPConnection` instance represents one transaction with an HTTP
40-
server. It should be instantiated passing it a host and optional port
40+
server. It should be instantiated by passing it a host and optional port
4141
number. If no port number is passed, the port is extracted from the host
4242
string if it has the form ``host:port``, else the default HTTP port (80) is
4343
used. If the optional *timeout* parameter is given, blocking
@@ -61,7 +61,7 @@ The module provides the following classes:
6161

6262
.. versionchanged:: 3.4
6363
The *strict* parameter was removed. HTTP 0.9-style "Simple Responses" are
64-
not longer supported.
64+
no longer supported.
6565

6666
.. versionchanged:: 3.7
6767
*blocksize* parameter was added.
@@ -474,7 +474,7 @@ statement.
474474

475475
Return the value of the header *name*, or *default* if there is no header
476476
matching *name*. If there is more than one header with the name *name*,
477-
return all of the values joined by ', '. If 'default' is any iterable other
477+
return all of the values joined by ', '. If *default* is any iterable other
478478
than a single string, its elements are similarly returned joined by commas.
479479

480480
.. method:: HTTPResponse.getheaders()
@@ -578,7 +578,7 @@ Here is an example session that uses the ``HEAD`` method. Note that the
578578
>>> data == b''
579579
True
580580

581-
Here is an example session that shows how to ``POST`` requests::
581+
Here is an example session that uses the ``POST`` method::
582582

583583
>>> import http.client, urllib.parse
584584
>>> params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
@@ -594,14 +594,13 @@ Here is an example session that shows how to ``POST`` requests::
594594
b'Redirecting to <a href="https://bugs.python.org/issue12524">https://bugs.python.org/issue12524</a>'
595595
>>> conn.close()
596596

597-
Client side ``HTTP PUT`` requests are very similar to ``POST`` requests. The
598-
difference lies only the server side where HTTP server will allow resources to
599-
be created via ``PUT`` request. It should be noted that custom HTTP methods
597+
Client side HTTP ``PUT`` requests are very similar to ``POST`` requests. The
598+
difference lies only on the server side where HTTP servers will allow resources to
599+
be created via ``PUT`` requests. It should be noted that custom HTTP methods
600600
are also handled in :class:`urllib.request.Request` by setting the appropriate
601-
method attribute. Here is an example session that shows how to send a ``PUT``
602-
request using http.client::
601+
method attribute. Here is an example session that uses the ``PUT`` method::
603602

604-
>>> # This creates an HTTP message
603+
>>> # This creates an HTTP request
605604
>>> # with the content of BODY as the enclosed representation
606605
>>> # for the resource http://localhost:8080/file
607606
...

‎Doc/library/multiprocessing.rst‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,6 @@ The :mod:`multiprocessing` package mostly replicates the API of the
674674
Example usage of some of the methods of :class:`Process`:
675675

676676
.. doctest::
677-
:options: +ELLIPSIS
678677

679678
>>> import multiprocessing, time, signal
680679
>>> p = multiprocessing.Process(target=time.sleep, args=(1000,))

‎Doc/using/windows.rst‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,14 @@ of available options is shown below.
163163
| | | Python X.Y` |
164164
+---------------------------+--------------------------------------+--------------------------+
165165
| DefaultJustForMeTargetDir | The default install directory for | :file:`%LocalAppData%\\\ |
166-
| | just-for-me installs | Programs\\PythonXY` or |
166+
| | just-for-me installs | Programs\\Python\\\ |
167+
| | | PythonXY` or |
167168
| | | :file:`%LocalAppData%\\\ |
168-
| | | Programs\\PythonXY-32` or|
169+
| | | Programs\\Python\\\ |
170+
| | | PythonXY-32` or |
169171
| | | :file:`%LocalAppData%\\\ |
170-
| | | Programs\\PythonXY-64` |
172+
| | | Programs\\Python\\\ |
173+
| | | PythonXY-64` |
171174
+---------------------------+--------------------------------------+--------------------------+
172175
| DefaultCustomTargetDir | The default custom install directory | (empty) |
173176
| | displayed in the UI | |

‎Doc/whatsnew/3.11.rst‎

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,27 +529,51 @@ New Modules
529529
Improved Modules
530530
================
531531

532+
.. _whatsnew311-asyncio:
533+
532534
asyncio
533535
-------
534536

535-
* Add raw datagram socket functions to the event loop:
536-
:meth:`~asyncio.AbstractEventLoop.sock_sendto`,
537-
:meth:`~asyncio.AbstractEventLoop.sock_recvfrom` and
538-
:meth:`~asyncio.AbstractEventLoop.sock_recvfrom_into`.
539-
(Contributed by Alex Grönholm in :issue:`46805`.)
540-
541-
* Add :meth:`~asyncio.streams.StreamWriter.start_tls` method for upgrading
542-
existing stream-based connections to TLS. (Contributed by Ian Good in
543-
:issue:`34975`.)
544-
545-
* Add :class:`~asyncio.Barrier` class to the synchronization primitives of
546-
the asyncio library. (Contributed by Yves Duprat and Andrew Svetlov in
547-
:gh:`87518`.)
548-
549-
* Add :class:`~asyncio.TaskGroup` class,
537+
* Added the :class:`~asyncio.TaskGroup` class,
550538
an :ref:`asynchronous context manager <async-context-managers>`
551539
holding a group of tasks that will wait for all of them upon exit.
552-
(Contributed by Yury Seliganov and others.)
540+
For new code this is recommended over using
541+
:func:`~asyncio.create_task` and :func:`~asyncio.gather` directly.
542+
(Contributed by Yury Selivanov and others in :gh:`90908`.)
543+
544+
* Added :func:`~asyncio.timeout`, an asynchronous context manager for
545+
setting a timeout on asynchronous operations. For new code this is
546+
recommended over using :func:`~asyncio.wait_for` directly.
547+
(Contributed by Andrew Svetlov in :gh:`90927`.)
548+
549+
* Added the :class:`~asyncio.Runner` class, which exposes the machinery
550+
used by :func:`~asyncio.run`.
551+
(Contributed by Andrew Svetlov in :gh:`91218`.)
552+
553+
* Added the :class:`~asyncio.Barrier` class to the synchronization
554+
primitives in the asyncio library, and the related
555+
:exc:`~asyncio.BrokenBarrierError` exception.
556+
(Contributed by Yves Duprat and Andrew Svetlov in :gh:`87518`.)
557+
558+
* Added keyword argument *all_errors* to :meth:`asyncio.loop.create_connection`
559+
so that multiple connection errors can be raised as an :exc:`ExceptionGroup`.
560+
561+
* Added the :meth:`asyncio.StreamWriter.start_tls` method for
562+
upgrading existing stream-based connections to TLS.
563+
(Contributed by Ian Good in :issue:`34975`.)
564+
565+
* Added raw datagram socket functions to the event loop:
566+
:meth:`~asyncio.loop.sock_sendto`,
567+
:meth:`~asyncio.loop.sock_recvfrom` and
568+
:meth:`~asyncio.loop.sock_recvfrom_into`.
569+
These have implementations in :class:`~asyncio.SelectorEventLoop` and
570+
:class:`~asyncio.ProactorEventLoop`.
571+
(Contributed by Alex Grönholm in :issue:`46805`.)
572+
573+
* Added :meth:`~asyncio.Task.cancelling` and
574+
:meth:`~asyncio.Task.uncancel` methods to :class:`~asyncio.Task`.
575+
These are primarily intended for internal use,
576+
notably by :class:`~asyncio.TaskGroup`.
553577

554578
contextlib
555579
----------

‎Doc/whatsnew/3.12.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ Demos and Tools
178178
<https://github.com/gvanrossum/old-demos>`_.
179179
(Contributed by Victor Stinner in :gh:`97681`.)
180180

181+
* Remove outdated example scripts of the ``Tools/scripts/`` directory.
182+
A copy can be found in the `old-demos project
183+
<https://github.com/gvanrossum/old-demos>`_.
184+
(Contributed by Victor Stinner in :gh:`97669`.)
185+
181186

182187
Deprecated
183188
==========

‎Lib/dataclasses.py‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,25 @@ class _DataclassParams:
320320
'order',
321321
'unsafe_hash',
322322
'frozen',
323+
'match_args',
324+
'kw_only',
325+
'slots',
326+
'weakref_slot',
323327
)
324328

325-
def __init__(self, init, repr, eq, order, unsafe_hash, frozen):
329+
def __init__(self,
330+
init, repr, eq, order, unsafe_hash, frozen,
331+
match_args, kw_only, slots, weakref_slot):
326332
self.init = init
327333
self.repr = repr
328334
self.eq = eq
329335
self.order = order
330336
self.unsafe_hash = unsafe_hash
331337
self.frozen = frozen
338+
self.match_args = match_args
339+
self.kw_only = kw_only
340+
self.slots = slots
341+
self.weakref_slot = weakref_slot
332342

333343
def __repr__(self):
334344
return ('_DataclassParams('
@@ -337,7 +347,11 @@ def __repr__(self):
337347
f'eq={self.eq!r},'
338348
f'order={self.order!r},'
339349
f'unsafe_hash={self.unsafe_hash!r},'
340-
f'frozen={self.frozen!r}'
350+
f'frozen={self.frozen!r},'
351+
f'match_args={self.match_args!r},'
352+
f'kw_only={self.kw_only!r},'
353+
f'slots={self.slots!r},'
354+
f'weakref_slot={self.weakref_slot!r}'
341355
')')
342356

343357

@@ -429,6 +443,10 @@ def _create_fn(name, args, body, *, globals=None, locals=None,
429443
# Compute the text of the entire function.
430444
txt = f' def {name}({args}){return_annotation}:\n{body}'
431445

446+
# Free variables in exec are resolved in the global namespace.
447+
# The global namespace we have is user-provided, so we can't modify it for
448+
# our purposes. So we put the things we need into locals and introduce a
449+
# scope to allow the function we're creating to close over them.
432450
local_vars = ', '.join(locals.keys())
433451
txt = f"def __create_fn__({local_vars}):\n{txt}\n return {name}"
434452
ns = {}
@@ -901,7 +919,9 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
901919
globals = {}
902920

903921
setattr(cls, _PARAMS, _DataclassParams(init, repr, eq, order,
904-
unsafe_hash, frozen))
922+
unsafe_hash, frozen,
923+
match_args, kw_only,
924+
slots, weakref_slot))
905925

906926
# Find our base classes in reverse MRO order, and exclude
907927
# ourselves. In reversed order so that more derived classes
@@ -920,10 +940,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
920940
if getattr(b, _PARAMS).frozen:
921941
any_frozen_base = True
922942

923-
# Annotations that are defined in this class (not in base
924-
# classes). If __annotations__ isn't present, then this class
925-
# adds no new annotations. We use this to compute fields that are
926-
# added by this class.
943+
# Annotations defined specifically in this class (not in base classes).
927944
#
928945
# Fields are found from cls_annotations, which is guaranteed to be
929946
# ordered. Default values are from class attributes, if a field
@@ -932,7 +949,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
932949
# actual default value. Pseudo-fields ClassVars and InitVars are
933950
# included, despite the fact that they're not real fields. That's
934951
# dealt with later.
935-
cls_annotations = cls.__dict__.get('__annotations__', {})
952+
cls_annotations = inspect.get_annotations(cls)
936953

937954
# Now find fields in our class. While doing so, validate some
938955
# things, and set the default values (as class attributes) where

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL