Accepting request 1126958 from devel:languages:python

- update to 3.7.1:
  * Fixed sending large buffers via UNIX stream sockets on
    asyncio
  * Fixed several minor documentation issues (broken links to
    classes, missing classes or attributes)
  * Dropped support for Python 3.6
  * Improved type annotations:
  * Several functions and methods that were previously annotated
    as accepting ``Coroutine[Any, Any, Any]`` as the return type
    of the callable have been amended to accept ``Awaitable[Any]``
    instead, to allow a slightly broader set of coroutine-like
    inputs, like ``async_generator_asend`` objects returned from
    the ``asend()`` method of async generators, and to match
    the ``trio`` annotations:
    * ``anyio.run()``
    * ``anyio.from_thread.run()``
    * ``TaskGroup.start_soon()``
    * ``TaskGroup.start()``
    * ``BlockingPortal.call()``
    * ``BlockingPortal.start_task_soon()``
    * ``BlockingPortal.start_task()``
  * Changed ``TLSAttribute.shared_ciphers`` to match the
    documented semantics of ``SSLSocket.shared_ciphers``
    of always returning ``None`` for client-side streams
  * Fixed ``CapacityLimiter`` on the asyncio backend to order
    waiting tasks in the FIFO order (instead of LIFO)
  * Fixed ``CancelScope.cancel()`` not working on asyncio if
    called before entering the scope
  * Fixed ``open_signal_receiver()`` inconsistently yielding
    integers instead of ``signal.Signals`` instances on the

OBS-URL: https://build.opensuse.org/request/show/1126958
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-anyio?expand=0&rev=18
This commit is contained in:
Ana Guerrero 2023-11-23 20:38:43 +00:00 committed by Git OBS Bridge
commit 217940d961
6 changed files with 155 additions and 241 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:25ea0d673ae30af41a0c442f81cf3b38c7e79fdc7b60335a4c14e05eb0947421
size 140378

BIN
anyio-3.7.1.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,203 +0,0 @@
From 6fd70f39b3a79ea406d994f3b437d8887d2f6e70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= <alex.gronholm@nextday.fi>
Date: Sun, 16 Apr 2023 17:47:21 +0300
Subject: [PATCH 1/7] Changed TLSAttribute.shared_ciphers to match
SSLSocket.shared_ciphers()
---
docs/versionhistory.rst | 2 ++
src/anyio/streams/tls.py | 9 +++--
tests/streams/test_tls.py | 74 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 81 insertions(+), 4 deletions(-)
Index: anyio-3.6.2/src/anyio/streams/tls.py
===================================================================
--- anyio-3.6.2.orig/src/anyio/streams/tls.py
+++ anyio-3.6.2/src/anyio/streams/tls.py
@@ -37,8 +37,9 @@ class TLSAttribute(TypedAttributeSet):
peer_certificate_binary: Optional[bytes] = typed_attribute()
#: ``True`` if this is the server side of the connection
server_side: bool = typed_attribute()
- #: ciphers shared between both ends of the TLS connection
- shared_ciphers: List[Tuple[str, str, int]] = typed_attribute()
+ #: ciphers shared by the client during the TLS handshake (``None`` if this is the
+ #: client side)
+ shared_ciphers: Optional[list[tuple[str, str, int]]] = typed_attribute()
#: the :class:`~ssl.SSLObject` used for encryption
ssl_object: ssl.SSLObject = typed_attribute()
#: ``True`` if this stream does (and expects) a closing TLS handshake when the stream is being
@@ -105,7 +106,8 @@ class TLSStream(ByteStream):
# Re-enable detection of unexpected EOFs if it was disabled by Python
if hasattr(ssl, "OP_IGNORE_UNEXPECTED_EOF"):
- ssl_context.options ^= ssl.OP_IGNORE_UNEXPECTED_EOF # type: ignore[attr-defined]
+ ssl_context.options &= ~ssl.OP_IGNORE_UNEXPECTED_EOF # type: ignore[attr-defined]
+
bio_in = ssl.MemoryBIO()
bio_out = ssl.MemoryBIO()
@@ -153,7 +155,7 @@ class TLSStream(ByteStream):
self._read_bio.write_eof()
self._write_bio.write_eof()
if (
- isinstance(exc, ssl.SSLEOFError)
+ isinstance(exc, (ssl.SSLEOFError, ssl.SSLZeroReturnError))
or "UNEXPECTED_EOF_WHILE_READING" in exc.strerror
):
if self.standard_compatible:
@@ -228,7 +230,9 @@ class TLSStream(ByteStream):
True
),
TLSAttribute.server_side: lambda: self._ssl_object.server_side,
- TLSAttribute.shared_ciphers: lambda: self._ssl_object.shared_ciphers(),
+ TLSAttribute.shared_ciphers: lambda: self._ssl_object.shared_ciphers()
+ if self._ssl_object.server_side
+ else None,
TLSAttribute.standard_compatible: lambda: self.standard_compatible,
TLSAttribute.ssl_object: lambda: self._ssl_object,
TLSAttribute.tls_version: self._ssl_object.version,
Index: anyio-3.6.2/tests/streams/test_tls.py
===================================================================
--- anyio-3.6.2.orig/tests/streams/test_tls.py
+++ anyio-3.6.2/tests/streams/test_tls.py
@@ -5,6 +5,7 @@ from threading import Thread
from typing import ContextManager, NoReturn
import pytest
+from pytest_mock import MockerFixture
from trustme import CA
from anyio import (
@@ -12,10 +13,13 @@ from anyio import (
EndOfStream,
Event,
connect_tcp,
+ create_memory_object_stream,
create_task_group,
create_tcp_listener,
+ to_thread,
)
from anyio.abc import AnyByteStream, SocketAttribute, SocketStream
+from anyio.streams.stapled import StapledObjectStream
from anyio.streams.tls import TLSAttribute, TLSListener, TLSStream
pytestmark = pytest.mark.anyio
@@ -95,7 +99,7 @@ class TestTLSStream:
wrapper.extra(TLSAttribute.peer_certificate_binary), bytes
)
assert wrapper.extra(TLSAttribute.server_side) is False
- assert isinstance(wrapper.extra(TLSAttribute.shared_ciphers), list)
+ assert wrapper.extra(TLSAttribute.shared_ciphers) is None
assert isinstance(wrapper.extra(TLSAttribute.ssl_object), ssl.SSLObject)
assert wrapper.extra(TLSAttribute.standard_compatible) is False
assert wrapper.extra(TLSAttribute.tls_version).startswith("TLSv")
@@ -368,6 +372,20 @@ class TestTLSStream:
server_thread.join()
server_sock.close()
+ @pytest.mark.skipif(
+ not hasattr(ssl, "OP_IGNORE_UNEXPECTED_EOF"),
+ reason="The ssl module does not have the OP_IGNORE_UNEXPECTED_EOF attribute",
+ )
+ async def test_default_context_ignore_unexpected_eof_flag_off(
+ self, mocker: MockerFixture
+ ) -> None:
+ send1, receive1 = create_memory_object_stream()
+ client_stream = StapledObjectStream(send1, receive1)
+ mocker.patch.object(TLSStream, "_call_sslobject_method")
+ tls_stream = await TLSStream.wrap(client_stream)
+ ssl_context = tls_stream.extra(TLSAttribute.ssl_object).context
+ assert not ssl_context.options & ssl.OP_IGNORE_UNEXPECTED_EOF
+
class TestTLSListener:
async def test_handshake_fail(self, server_context: ssl.SSLContext) -> None:
@@ -399,3 +417,74 @@ class TestTLSListener:
tg.cancel_scope.cancel()
assert isinstance(exception, BrokenResourceError)
+
+ async def test_extra_attributes(
+ self, client_context: ssl.SSLContext, server_context: ssl.SSLContext, ca: CA
+ ) -> None:
+ def connect_sync(addr: tuple[str, int]) -> None:
+ with socket.create_connection(addr) as plain_sock:
+ plain_sock.settimeout(2)
+ with client_context.wrap_socket(
+ plain_sock,
+ server_side=False,
+ server_hostname="localhost",
+ suppress_ragged_eofs=False,
+ ) as conn:
+ conn.recv(1)
+ conn.unwrap()
+
+ class CustomTLSListener(TLSListener):
+ @staticmethod
+ async def handle_handshake_error(
+ exc: BaseException, stream: AnyByteStream
+ ) -> None:
+ await TLSListener.handle_handshake_error(exc, stream)
+ pytest.fail("TLS handshake failed")
+
+ async def handler(stream: TLSStream) -> None:
+ async with stream:
+ try:
+ assert stream.extra(TLSAttribute.alpn_protocol) == "h2"
+ assert isinstance(
+ stream.extra(TLSAttribute.channel_binding_tls_unique), bytes
+ )
+ assert isinstance(stream.extra(TLSAttribute.cipher), tuple)
+ assert isinstance(stream.extra(TLSAttribute.peer_certificate), dict)
+ assert isinstance(
+ stream.extra(TLSAttribute.peer_certificate_binary), bytes
+ )
+ assert stream.extra(TLSAttribute.server_side) is True
+ shared_ciphers = stream.extra(TLSAttribute.shared_ciphers)
+ assert isinstance(shared_ciphers, list)
+ assert len(shared_ciphers) > 1
+ assert isinstance(
+ stream.extra(TLSAttribute.ssl_object), ssl.SSLObject
+ )
+ assert stream.extra(TLSAttribute.standard_compatible) is True
+ assert stream.extra(TLSAttribute.tls_version).startswith("TLSv")
+ finally:
+ event.set()
+ await stream.send(b"\x00")
+
+ # Issue a client certificate and make the server trust it
+ client_cert = ca.issue_cert("dummy-client")
+ client_cert.configure_cert(client_context)
+ ca.configure_trust(server_context)
+ server_context.verify_mode = ssl.CERT_REQUIRED
+
+ event = Event()
+ server_context.set_alpn_protocols(["h2"])
+ client_context.set_alpn_protocols(["h2"])
+ listener = await create_tcp_listener(local_host="127.0.0.1")
+ tls_listener = CustomTLSListener(listener, server_context)
+ async with tls_listener, create_task_group() as tg:
+ assert tls_listener.extra(TLSAttribute.standard_compatible) is True
+ tg.start_soon(tls_listener.serve, handler)
+ client_thread = Thread(
+ target=connect_sync,
+ args=[listener.extra(SocketAttribute.local_address)],
+ )
+ client_thread.start()
+ await event.wait()
+ await to_thread.run_sync(client_thread.join)
+ tg.cancel_scope.cancel()
Index: anyio-3.6.2/tests/conftest.py
===================================================================
--- anyio-3.6.2.orig/tests/conftest.py
+++ anyio-3.6.2/tests/conftest.py
@@ -54,7 +54,8 @@ def ca() -> CA:
def server_context(ca: CA) -> SSLContext:
server_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
if hasattr(ssl, "OP_IGNORE_UNEXPECTED_EOF"):
- server_context.options ^= ssl.OP_IGNORE_UNEXPECTED_EOF # type: ignore[attr-defined]
+ server_context.options &= ~ssl.OP_IGNORE_UNEXPECTED_EOF # type: ignore[attr-defined]
+
ca.issue_cert("localhost").configure_cert(server_context)
return server_context

View File

@ -1,3 +1,141 @@
-------------------------------------------------------------------
Thu Nov 16 15:31:07 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 3.7.1:
* Fixed sending large buffers via UNIX stream sockets on
asyncio
* Fixed several minor documentation issues (broken links to
classes, missing classes or attributes)
* Dropped support for Python 3.6
* Improved type annotations:
* Several functions and methods that were previously annotated
as accepting ``Coroutine[Any, Any, Any]`` as the return type
of the callable have been amended to accept ``Awaitable[Any]``
instead, to allow a slightly broader set of coroutine-like
inputs, like ``async_generator_asend`` objects returned from
the ``asend()`` method of async generators, and to match
the ``trio`` annotations:
* ``anyio.run()``
* ``anyio.from_thread.run()``
* ``TaskGroup.start_soon()``
* ``TaskGroup.start()``
* ``BlockingPortal.call()``
* ``BlockingPortal.start_task_soon()``
* ``BlockingPortal.start_task()``
* Changed ``TLSAttribute.shared_ciphers`` to match the
documented semantics of ``SSLSocket.shared_ciphers``
of always returning ``None`` for client-side streams
* Fixed ``CapacityLimiter`` on the asyncio backend to order
waiting tasks in the FIFO order (instead of LIFO)
* Fixed ``CancelScope.cancel()`` not working on asyncio if
called before entering the scope
* Fixed ``open_signal_receiver()`` inconsistently yielding
integers instead of ``signal.Signals`` instances on the
``trio`` backend
* Fixed ``to_thread.run_sync()`` hanging on asyncio if the
target callable raises ``StopIteration``
* Fixed ``start_blocking_portal()`` raising an unwarranted
* ``RuntimeError: This portal is not running`` if a task raises
an exception that causes the event loop to be closed
* Fixed ``current_effective_deadline()`` not returning ``-inf``
on asyncio when the currently active cancel scope has been
cancelled (PR by Ganden Schaffner)
* Fixed the ``OP_IGNORE_UNEXPECTED_EOF`` flag in an SSL context
created by default in ``TLSStream.wrap()`` being inadvertently
set on Python 3.11.3 and 3.10.11
* Fixed ``CancelScope`` to properly handle asyncio task
uncancellation on Python 3.11
* Fixed ``OSError`` when trying to use
``create_tcp_listener()`` to bind to a link-local
* IPv6 address (and worked around related bugs in ``uvloop``)
* Worked around a `PyPy bug
<https://foss.heptapod.net/pypy/pypy/-/issues/3938>`_
when using ``anyio.getaddrinfo()`` with for IPv6 link-local
addresses containing interface names
- drop fix-failing-tls-tests.patch
support-trio-0.22.patch: obsolete
-------------------------------------------------------------------
Thu Nov 16 15:30:25 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 3.7.1:
* Fixed sending large buffers via UNIX stream sockets on
asyncio
* Fixed several minor documentation issues (broken links to
classes, missing classes or
* attributes)
* **3.7.0**
* Dropped support for Python 3.6
* Improved type annotations:
* Several functions and methods that were previously annotated
as accepting
* ``Coroutine[Any, Any, Any]`` as the return type of the
callable have been amended to
* accept ``Awaitable[Any]`` instead, to allow a slightly
broader set of coroutine-like
* inputs, like ``async_generator_asend`` objects returned from
the ``asend()`` method
* of async generators, and to match the ``trio`` annotations:
* ``anyio.run()``
* ``anyio.from_thread.run()``
* ``TaskGroup.start_soon()``
* ``TaskGroup.start()``
* ``BlockingPortal.call()``
* ``BlockingPortal.start_task_soon()``
* ``BlockingPortal.start_task()``
* Note that this change involved only changing the type
annotations; run-time
* functionality was not altered.
* The ``TaskStatus`` class is now a generic protocol, and
should be parametrized to
* indicate the type of the value passed to
``task_status.started()``
* The ``Listener`` class is now covariant in its stream type
* ``create_memory_object_stream()`` now allows passing only
``item_type``
* Object receive streams are now covariant and object send
streams are correspondingly
* contravariant
* Changed ``TLSAttribute.shared_ciphers`` to match the
documented semantics of
* ``SSLSocket.shared_ciphers`` of always returning ``None`` for
client-side streams
* Fixed ``CapacityLimiter`` on the asyncio backend to order
waiting tasks in the FIFO
* order (instead of LIFO) (PR by Conor Stevenson)
* Fixed ``CancelScope.cancel()`` not working on asyncio if
called before entering the
* scope
* Fixed ``open_signal_receiver()`` inconsistently yielding
integers instead of
* ``signal.Signals`` instances on the ``trio`` backend
* Fixed ``to_thread.run_sync()`` hanging on asyncio if the
target callable raises
* ``StopIteration``
* Fixed ``start_blocking_portal()`` raising an unwarranted
* ``RuntimeError: This portal is not running`` if a task raises
an exception that causes
* the event loop to be closed
* Fixed ``current_effective_deadline()`` not returning ``-inf``
on asyncio when the
* currently active cancel scope has been cancelled (PR by
Ganden Schaffner)
* Fixed the ``OP_IGNORE_UNEXPECTED_EOF`` flag in an SSL context
created by default in
* ``TLSStream.wrap()`` being inadvertently set on Python 3.11.3
and 3.10.11
* Fixed ``CancelScope`` to properly handle asyncio task
uncancellation on Python 3.11
* (PR by Nikolay Bryskin)
* Fixed ``OSError`` when trying to use
``create_tcp_listener()`` to bind to a link-local
* IPv6 address (and worked around related bugs in ``uvloop``)
* Worked around a `PyPy bug
<https://foss.heptapod.net/pypy/pypy/-/issues/3938>`_
* when using ``anyio.getaddrinfo()`` with for IPv6 link-local
addresses containing
* interface names
-------------------------------------------------------------------
Thu Nov 2 10:42:51 UTC 2023 - Jiri Slaby <jslaby@suse.cz>
@ -8,7 +146,7 @@ Thu Nov 2 10:42:51 UTC 2023 - Jiri Slaby <jslaby@suse.cz>
Thu May 4 07:29:22 UTC 2023 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch fix-failing-tls-tests.patch:
* Fix test failures with Python TLS changes.
* Fix test failures with Python TLS changes.
-------------------------------------------------------------------
Fri Apr 21 12:21:49 UTC 2023 - Dirk Müller <dmueller@suse.com>
@ -29,7 +167,7 @@ Tue Mar 7 06:29:28 UTC 2023 - Steve Kowalik <steven.kowalik@suse.com>
-------------------------------------------------------------------
Fri Dec 16 15:06:08 UTC 2022 - Markéta Machová <mmachova@suse.com>
- Skip trio exception tests for now
- Skip trio exception tests for now
* https://github.com/agronholm/anyio/issues/508
* https://github.com/agronholm/anyio/commit/787cb0c2e53c2a3307873d202fbd49dc5eac4e96
@ -59,7 +197,7 @@ Sun Mar 27 18:32:27 UTC 2022 - Ben Greiner <code@bnavigator.de>
-------------------------------------------------------------------
Tue Feb 15 16:06:39 UTC 2022 - Dirk Müller <dmueller@suse.com>
- skip some tests for older distros (lack of TLSv1.3 support)
- skip some tests for older distros (lack of TLSv1.3 support)
-------------------------------------------------------------------
Sat Jan 15 16:36:24 UTC 2022 - Dirk Müller <dmueller@suse.com>
@ -102,7 +240,7 @@ Sat Oct 16 21:03:37 UTC 2021 - Dirk Müller <dmueller@suse.com>
* Changed unconnected UDP sockets to be always bound to a local port (on
"any" interface) to avoid errors on asyncio + Windows
* Fixed cancellation problem on asyncio where level-triggered cancellation
for **all** parent cancel scopes would not resume after exiting a
for **all** parent cancel scopes would not resume after exiting a
shielded nested scope
-------------------------------------------------------------------

View File

@ -18,26 +18,24 @@
%{?sle15_python_module_pythons}
Name: python-anyio
Version: 3.6.2
Version: 3.7.1
Release: 0
Summary: High level compatibility layer for asynchronous event loop implementations
License: MIT
URL: https://github.com/agronholm/anyio
Source: https://files.pythonhosted.org/packages/source/a/anyio/anyio-%{version}.tar.gz
# PATCH-FIX-OPENSUSE Support trio >= 0.22 just enough for asyncclick
Patch0: support-trio-0.22.patch
# PATCH-FIX-UPSTREAM Based on gh#agronholm/anyio#553
Patch1: fix-failing-tls-tests.patch
# PATCH-FIX-UPSTREAM see gh#agronholm/anyio#626
Patch2: tests-test_fileio.py-don-t-follow-symlinks-in-dev.patch
BuildRequires: %{python_module contextlib2 if %python-base < 3.7}
BuildRequires: %{python_module dataclasses if %python-base < 3.7}
BuildRequires: %{python_module idna >= 2.8}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module psutil >= 5.9}
BuildRequires: %{python_module setuptools_scm}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module sniffio >= 1.1}
BuildRequires: %{python_module toml}
BuildRequires: %{python_module typing_extensions if %python-base < 3.8}
BuildRequires: %{python_module wheel}
BuildRequires: python-rpm-macros >= 20210127.3a18043
# SECTION test requirements
BuildRequires: %{python_module hypothesis >= 4.0}
@ -69,10 +67,10 @@ against it to run unmodified on asyncio, curio and trio.
%autosetup -p1 -n anyio-%{version}
%build
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
@ -85,13 +83,16 @@ donttest+=" or (TestUDPSocket and (ipv4 or ipv6))"
# wrong localhost address
donttest+=" or (TestTCPStream and test_happy_eyeballs)"
donttest+=" or (TestTCPStream and test_connection_refused)"
donttest+=" or test_bind_link_local"
# does not raise an exception
donttest+=" or (TestTLSStream and test_ragged_eofs)"
%if 0%{?suse_version} < 1550
donttest+=" or (test_send_eof_not_implemented)"
%endif
# anyio 3.6.2 and lower is broken with new trio, some tests fail https://github.com/agronholm/anyio/commit/787cb0c2e53c2a3307873d202fbd49dc5eac4e96
donttest+=" or (test_exception_group and trio)"
# Fail with python 3.12
donttest+=" or (test_properties and trio)"
donttest+=" or (test_properties and asyncio)"
%pytest -m "not network" -k "not (${donttest:4})" -ra
%files %{python_files}

View File

@ -1,22 +0,0 @@
Index: anyio-3.6.2/src/anyio/_backends/_trio.py
===================================================================
--- anyio-3.6.2.orig/src/anyio/_backends/_trio.py
+++ anyio-3.6.2/src/anyio/_backends/_trio.py
@@ -161,7 +161,7 @@ current_time = trio.current_time
#
-class ExceptionGroup(BaseExceptionGroup, trio.MultiError):
+class ExceptionGroup(BaseExceptionGroup):
pass
@@ -185,7 +185,7 @@ class TaskGroup(abc.TaskGroup):
) -> Optional[bool]:
try:
return await self._nursery_manager.__aexit__(exc_type, exc_val, exc_tb)
- except trio.MultiError as exc:
+ except ExceptionGroup as exc:
raise ExceptionGroup(exc.exceptions) from None
finally:
self._active = False