Skip to content

Commit

Permalink
Merge branch 'main' into inlinecomp2
Browse files Browse the repository at this point in the history
* main:
  pythongh-98831: rewrite PUSH_EXC_INFO and conditional jumps in the instruction definition DSL (python#101481)
  pythongh-98831: Modernize the LOAD_ATTR family (python#101488)
  pythongh-101498 : Fix asyncio.Timeout example in docs (python#101499)
  pythongh-101454: fix documentation for END_ASYNC_FOR (python#101455)
  pythongh-101277: Isolate itertools, add group and _grouper types to module state (python#101302)
  pythongh-101317: Add `ssl_shutdown_timeout` parameter for `asyncio.StreamWriter.start_tls` (python#101335)
  datetime.rst: fix combine() signature (python#101490)
  • Loading branch information
carljm committed Feb 1, 2023
2 parents db208d5 + b91b42d commit 8b76051
Show file tree
Hide file tree
Showing 14 changed files with 496 additions and 449 deletions.
10 changes: 9 additions & 1 deletion Doc/library/asyncio-stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ StreamWriter
returns immediately.

.. coroutinemethod:: start_tls(sslcontext, \*, server_hostname=None, \
ssl_handshake_timeout=None)
ssl_handshake_timeout=None, ssl_shutdown_timeout=None)

Upgrade an existing stream-based connection to TLS.

Expand All @@ -350,8 +350,16 @@ StreamWriter
handshake to complete before aborting the connection. ``60.0`` seconds
if ``None`` (default).

* *ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown
to complete before aborting the connection. ``30.0`` seconds if ``None``
(default).

.. versionadded:: 3.11

.. versionchanged:: 3.12
Added the *ssl_shutdown_timeout* parameter.


.. method:: is_closing()

Return ``True`` if the stream is closed or in the process of
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Timeouts
except TimeoutError:
pass

if cm.expired:
if cm.expired():
print("Looks like we haven't finished on time.")

Timeout context managers can be safely nested.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ Other constructors, all class methods:
microsecond of the result are all 0, and :attr:`.tzinfo` is ``None``.


.. classmethod:: datetime.combine(date, time, tzinfo=self.tzinfo)
.. classmethod:: datetime.combine(date, time, tzinfo=time.tzinfo)

Return a new :class:`.datetime` object whose date components are equal to the
given :class:`date` object's, and whose time components
Expand Down
7 changes: 3 additions & 4 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,9 @@ not have to be) the original ``STACK[-2]``.
.. opcode:: END_ASYNC_FOR

Terminates an :keyword:`async for` loop. Handles an exception raised
when awaiting a next item. If ``STACK[-1]`` is :exc:`StopAsyncIteration` pop 3
values from the stack and restore the exception state using the second
of them. Otherwise re-raise the exception using the value
from the stack. An exception handler block is removed from the block stack.
when awaiting a next item. The stack contains the async iterable in
``STACK[-2]`` and the raised exception in ``STACK[-1]``. Both are popped.
If the exception is not :exc:`StopAsyncIteration`, it is re-raised.

.. versionadded:: 3.8

Expand Down
6 changes: 4 additions & 2 deletions Lib/asyncio/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,17 @@ async def drain(self):

async def start_tls(self, sslcontext, *,
server_hostname=None,
ssl_handshake_timeout=None):
ssl_handshake_timeout=None,
ssl_shutdown_timeout=None):
"""Upgrade an existing stream-based connection to TLS."""
server_side = self._protocol._client_connected_cb is not None
protocol = self._protocol
await self.drain()
new_transport = await self._loop.start_tls( # type: ignore
self._transport, protocol, sslcontext,
server_side=server_side, server_hostname=server_hostname,
ssl_handshake_timeout=ssl_handshake_timeout)
ssl_handshake_timeout=ssl_handshake_timeout,
ssl_shutdown_timeout=ssl_shutdown_timeout)
self._transport = new_transport
protocol._replace_writer(self)

Expand Down
32 changes: 32 additions & 0 deletions Lib/test/test_itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,38 @@ def test_zip_longest_result_gc(self):
gc.collect()
self.assertTrue(gc.is_tracked(next(it)))

@support.cpython_only
def test_immutable_types(self):
from itertools import _grouper, _tee, _tee_dataobject
dataset = (
accumulate,
batched,
chain,
combinations,
combinations_with_replacement,
compress,
count,
cycle,
dropwhile,
filterfalse,
groupby,
_grouper,
islice,
pairwise,
permutations,
product,
repeat,
starmap,
takewhile,
_tee,
_tee_dataobject,
zip_longest,
)
for tp in dataset:
with self.subTest(tp=tp):
with self.assertRaisesRegex(TypeError, "immutable"):
tp.foobar = 1


class TestExamples(unittest.TestCase):

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add *ssl_shutdown_timeout* parameter for :meth:`asyncio.StreamWriter.start_tls`.

8 changes: 4 additions & 4 deletions Modules/clinic/itertoolsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8b76051

Please sign in to comment.