| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ jobs: | |||
| 18 | 18 | - { project: 2, label: "release-blocker, deferred-blocker" } | |
| 19 | 19 | - { project: 3, label: expert-subinterpreters } | |
| 20 | 20 | - { project: 29, label: expert-asyncio } | |
| 21 | + - { project: 32, label: sprint } | ||
| 21 | 22 | ||
| 22 | 23 | steps: | |
| 23 | 24 | - uses: actions/add-to-project@v0.1.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,7 +189,7 @@ For convenience, some of these functions will always return a | |||
| 189 | 189 | .. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr) | |
| 190 | 190 | ||
| 191 | 191 | 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` | ||
| 193 | 193 | is used instead. It calls the Win32 function :c:func:`FormatMessage` to retrieve | |
| 194 | 194 | the Windows description of error code given by *ierr* or :c:func:`GetLastError`, | |
| 195 | 195 | then it constructs a tuple object whose first item is the *ierr* value and whose | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -735,7 +735,7 @@ Is it possible to write obfuscated one-liners in Python? | |||
| 735 | 735 | -------------------------------------------------------- | |
| 736 | 736 | ||
| 737 | 737 | 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:: | ||
| 739 | 739 | ||
| 740 | 740 | from functools import reduce | |
| 741 | 741 | ||
@@ -748,7 +748,7 @@ Yes. Usually this is done by nesting :keyword:`lambda` within | |||
| 748 | 748 | f(x,f), range(10)))) | |
| 749 | 749 | ||
| 750 | 750 | # 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, | ||
| 752 | 752 | Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM, | |
| 753 | 753 | Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro, | |
| 754 | 754 | 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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1632,9 +1632,12 @@ on Unix and :class:`ProactorEventLoop` on Windows. | |||
| 1632 | 1632 | import asyncio | |
| 1633 | 1633 | import selectors | |
| 1634 | 1634 | ||
| 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()) | ||
| 1638 | 1641 | ||
| 1639 | 1642 | ||
| 1640 | 1643 | .. availability:: Unix, Windows. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | 15 | -------------- | |
| 16 | 16 | ||
| 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 | ||
| 18 | 18 | HTTPS protocols. It is normally not used directly --- the module | |
| 19 | 19 | :mod:`urllib.request` uses it to handle URLs that use HTTP and HTTPS. | |
| 20 | 20 | ||
@@ -37,7 +37,7 @@ The module provides the following classes: | |||
| 37 | 37 | blocksize=8192) | |
| 38 | 38 | ||
| 39 | 39 | 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 | ||
| 41 | 41 | number. If no port number is passed, the port is extracted from the host | |
| 42 | 42 | string if it has the form ``host:port``, else the default HTTP port (80) is | |
| 43 | 43 | used. If the optional *timeout* parameter is given, blocking | |
@@ -61,7 +61,7 @@ The module provides the following classes: | |||
| 61 | 61 | ||
| 62 | 62 | .. versionchanged:: 3.4 | |
| 63 | 63 | The *strict* parameter was removed. HTTP 0.9-style "Simple Responses" are | |
| 64 | - not longer supported. | ||
| 64 | + no longer supported. | ||
| 65 | 65 | ||
| 66 | 66 | .. versionchanged:: 3.7 | |
| 67 | 67 | *blocksize* parameter was added. | |
@@ -474,7 +474,7 @@ statement. | |||
| 474 | 474 | ||
| 475 | 475 | Return the value of the header *name*, or *default* if there is no header | |
| 476 | 476 | 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 | ||
| 478 | 478 | than a single string, its elements are similarly returned joined by commas. | |
| 479 | 479 | ||
| 480 | 480 | .. method:: HTTPResponse.getheaders() | |
@@ -578,7 +578,7 @@ Here is an example session that uses the ``HEAD`` method. Note that the | |||
| 578 | 578 | >>> data == b'' | |
| 579 | 579 | True | |
| 580 | 580 | ||
| 581 | - Here is an example session that shows how to ``POST`` requests:: | ||
| 581 | + Here is an example session that uses the ``POST`` method:: | ||
| 582 | 582 | ||
| 583 | 583 | >>> import http.client, urllib.parse | |
| 584 | 584 | >>> 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:: | |||
| 594 | 594 | b'Redirecting to <a href="https://bugs.python.org/issue12524">https://bugs.python.org/issue12524</a>' | |
| 595 | 595 | >>> conn.close() | |
| 596 | 596 | ||
| 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 | ||
| 600 | 600 | 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:: | ||
| 603 | 602 | ||
| 604 | - >>> # This creates an HTTP message | ||
| 603 | + >>> # This creates an HTTP request | ||
| 605 | 604 | >>> # with the content of BODY as the enclosed representation | |
| 606 | 605 | >>> # for the resource http://localhost:8080/file | |
| 607 | 606 | ... | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -674,7 +674,6 @@ The :mod:`multiprocessing` package mostly replicates the API of the | |||
| 674 | 674 | Example usage of some of the methods of :class:`Process`: | |
| 675 | 675 | ||
| 676 | 676 | .. doctest:: | |
| 677 | - :options: +ELLIPSIS | ||
| 678 | 677 | ||
| 679 | 678 | >>> import multiprocessing, time, signal | |
| 680 | 679 | >>> p = multiprocessing.Process(target=time.sleep, args=(1000,)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -163,11 +163,14 @@ of available options is shown below. | |||
| 163 | 163 | | | | Python X.Y` | | |
| 164 | 164 | +---------------------------+--------------------------------------+--------------------------+ | |
| 165 | 165 | | 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 | | ||
| 167 | 168 | | | | :file:`%LocalAppData%\\\ | | |
| 168 | - | | | Programs\\PythonXY-32` or| | ||
| 169 | + | | | Programs\\Python\\\ | | ||
| 170 | + | | | PythonXY-32` or | | ||
| 169 | 171 | | | | :file:`%LocalAppData%\\\ | | |
| 170 | - | | | Programs\\PythonXY-64` | | ||
| 172 | + | | | Programs\\Python\\\ | | ||
| 173 | + | | | PythonXY-64` | | ||
| 171 | 174 | +---------------------------+--------------------------------------+--------------------------+ | |
| 172 | 175 | | DefaultCustomTargetDir | The default custom install directory | (empty) | | |
| 173 | 176 | | | displayed in the UI | | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -529,27 +529,51 @@ New Modules | |||
| 529 | 529 | Improved Modules | |
| 530 | 530 | ================ | |
| 531 | 531 | ||
| 532 | + .. _whatsnew311-asyncio: | ||
| 533 | + | ||
| 532 | 534 | asyncio | |
| 533 | 535 | ------- | |
| 534 | 536 | ||
| 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, | ||
| 550 | 538 | an :ref:`asynchronous context manager <async-context-managers>` | |
| 551 | 539 | 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`. | ||
| 553 | 577 | ||
| 554 | 578 | contextlib | |
| 555 | 579 | ---------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,6 +178,11 @@ Demos and Tools | |||
| 178 | 178 | <https://github.com/gvanrossum/old-demos>`_. | |
| 179 | 179 | (Contributed by Victor Stinner in :gh:`97681`.) | |
| 180 | 180 | ||
| 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 | + | ||
| 181 | 186 | ||
| 182 | 187 | Deprecated | |
| 183 | 188 | ========== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -320,15 +320,25 @@ class _DataclassParams: | |||
| 320 | 320 | 'order', | |
| 321 | 321 | 'unsafe_hash', | |
| 322 | 322 | 'frozen', | |
| 323 | + 'match_args', | ||
| 324 | + 'kw_only', | ||
| 325 | + 'slots', | ||
| 326 | + 'weakref_slot', | ||
| 323 | 327 | ) | |
| 324 | 328 | ||
| 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): | ||
| 326 | 332 | self.init = init | |
| 327 | 333 | self.repr = repr | |
| 328 | 334 | self.eq = eq | |
| 329 | 335 | self.order = order | |
| 330 | 336 | self.unsafe_hash = unsafe_hash | |
| 331 | 337 | 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 | ||
| 332 | 342 | ||
| 333 | 343 | def __repr__(self): | |
| 334 | 344 | return ('_DataclassParams(' | |
@@ -337,7 +347,11 @@ def __repr__(self): | |||
| 337 | 347 | f'eq={self.eq!r},' | |
| 338 | 348 | f'order={self.order!r},' | |
| 339 | 349 | 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}' | ||
| 341 | 355 | ')') | |
| 342 | 356 | ||
| 343 | 357 | ||
@@ -429,6 +443,10 @@ def _create_fn(name, args, body, *, globals=None, locals=None, | |||
| 429 | 443 | # Compute the text of the entire function. | |
| 430 | 444 | txt = f' def {name}({args}){return_annotation}:\n{body}' | |
| 431 | 445 | ||
| 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. | ||
| 432 | 450 | local_vars = ', '.join(locals.keys()) | |
| 433 | 451 | txt = f"def __create_fn__({local_vars}):\n{txt}\n return {name}" | |
| 434 | 452 | ns = {} | |
@@ -901,7 +919,9 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, | |||
| 901 | 919 | globals = {} | |
| 902 | 920 | ||
| 903 | 921 | 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)) | ||
| 905 | 925 | ||
| 906 | 926 | # Find our base classes in reverse MRO order, and exclude | |
| 907 | 927 | # ourselves. In reversed order so that more derived classes | |
@@ -920,10 +940,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, | |||
| 920 | 940 | if getattr(b, _PARAMS).frozen: | |
| 921 | 941 | any_frozen_base = True | |
| 922 | 942 | ||
| 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). | ||
| 927 | 944 | # | |
| 928 | 945 | # Fields are found from cls_annotations, which is guaranteed to be | |
| 929 | 946 | # 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, | |||
| 932 | 949 | # actual default value. Pseudo-fields ClassVars and InitVars are | |
| 933 | 950 | # included, despite the fact that they're not real fields. That's | |
| 934 | 951 | # dealt with later. | |
| 935 | - cls_annotations = cls.__dict__.get('__annotations__', {}) | ||
| 952 | + cls_annotations = inspect.get_annotations(cls) | ||
| 936 | 953 | ||
| 937 | 954 | # Now find fields in our class. While doing so, validate some | |
| 938 | 955 | # things, and set the default values (as class attributes) where | |
| Back | FazBrowse Home | New Git URL |
0 commit comments