Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into remove_multierror
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkdl committed Jan 11, 2024
2 parents e64d508 + d1cc062 commit 0547313
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.1.11
hooks:
- id: ruff
types: [file]
Expand Down
18 changes: 18 additions & 0 deletions docs/source/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ Release history

.. towncrier release notes start
Trio 0.24.0 (2024-01-10)
------------------------

Features
~~~~~~~~

- New helper classes: :class:`~.testing.RaisesGroup` and :class:`~.testing.Matcher`.

In preparation for changing the default of ``strict_exception_groups`` to `True`, we're introducing a set of helper classes that can be used in place of `pytest.raises <https://docs.pytest.org/en/stable/reference/reference.html#pytest.raises>`_ in tests, to check for an expected `ExceptionGroup`.
These are provisional, and only planned to be supplied until there's a good solution in ``pytest``. See https://github.com/pytest-dev/pytest/issues/11538 (`#2785 <https://github.com/python-trio/trio/issues/2785>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- ``MultiError`` has been fully removed, and all relevant trio functions now raise ExceptionGroups instead. This should not affect end users that have transitioned to using ``except*`` or catching ExceptionGroup/BaseExceptionGroup. (`#2891 <https://github.com/python-trio/trio/issues/2891>`__)


Trio 0.23.2 (2023-12-14)
------------------------

Expand Down
4 changes: 0 additions & 4 deletions newsfragments/2785.feature.rst

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/2891.deprecated.rst

This file was deleted.

43 changes: 4 additions & 39 deletions src/trio/_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

import trio

from ._abc import AsyncResource, ReceiveStream, SendStream
from ._core import ClosedResourceError, TaskStatus
from ._deprecate import deprecated
from ._highlevel_generic import StapledStream
from ._subprocess_platform import (
create_pipe_from_child_output,
Expand All @@ -28,7 +26,9 @@
from collections.abc import Awaitable, Callable, Mapping, Sequence
from io import TextIOWrapper

from typing_extensions import Self, TypeAlias
from typing_extensions import TypeAlias

from ._abc import ReceiveStream, SendStream


# Sphinx cannot parse the stringified version
Expand Down Expand Up @@ -101,7 +101,7 @@ def fileno(self) -> int:


@final
class Process(AsyncResource, metaclass=NoPublicConstructor):
class Process(metaclass=NoPublicConstructor):
r"""A child process. Like :class:`subprocess.Popen`, but async.
This class has no public constructor. The most common way to get a
Expand Down Expand Up @@ -223,41 +223,6 @@ def returncode(self) -> int | None:
self._close_pidfd()
return result

@deprecated(
"0.20.0",
thing="using trio.Process as an async context manager",
issue=1104,
instead="run_process or nursery.start(run_process, ...)",
)
async def __aenter__(self) -> Self:
return self

# Type ignore is for `Type of decorated function contains type "Any" ("Callable[[Process], Coroutine[Any, Any, None]]")`
@deprecated(
"0.20.0", issue=1104, instead="run_process or nursery.start(run_process, ...)"
)
async def aclose(self) -> None: # type: ignore[misc]
"""Close any pipes we have to the process (both input and output)
and wait for it to exit.
If cancelled, kills the process and waits for it to finish
exiting before propagating the cancellation.
"""
with trio.CancelScope(shield=True):
if self.stdin is not None:
await self.stdin.aclose()
if self.stdout is not None:
await self.stdout.aclose()
if self.stderr is not None:
await self.stderr.aclose()
try:
await self.wait()
finally:
if self._proc.returncode is None:
self.kill()
with trio.CancelScope(shield=True):
await self.wait()

def _close_pidfd(self) -> None:
if self._pidfd is not None:
trio.lowlevel.notify_closing(self._pidfd.fileno())
Expand Down
29 changes: 0 additions & 29 deletions src/trio/_tests/test_deprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,32 +260,3 @@ def test_module_with_deprecations(recwarn_always: pytest.WarningsRecorder) -> No

with pytest.raises(AttributeError):
module_with_deprecations.asdf # type: ignore[attr-defined] # noqa: B018 # "useless expression"


def test_tests_is_deprecated1() -> None:
with pytest.warns(TrioDeprecationWarning):
from trio import tests # warning on import

# warning on access of any member
with pytest.warns(TrioDeprecationWarning):
assert tests.test_abc # type: ignore[attr-defined]


def test_tests_is_deprecated2() -> None:
# warning on direct import of test since that accesses `__spec__`
with pytest.warns(TrioDeprecationWarning):
import trio.tests

with pytest.warns(TrioDeprecationWarning):
assert trio.tests.test_deprecate # type: ignore[attr-defined]


def test_tests_is_deprecated3() -> None:
import trio

# no warning on accessing the submodule
assert trio.tests

# only when accessing a submodule member
with pytest.warns(TrioDeprecationWarning):
assert trio.tests.test_abc # type: ignore[attr-defined]
33 changes: 0 additions & 33 deletions src/trio/_tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from trio.testing import RaisesGroup

from .. import (
ClosedResourceError,
Event,
Process,
_core,
Expand Down Expand Up @@ -171,38 +170,6 @@ async def test_multi_wait(background_process: BackgroundProcessType) -> None:
proc.kill()


# Test for deprecated 'async with process:' semantics
async def test_async_with_basics_deprecated(recwarn: pytest.WarningsRecorder) -> None:
async with await open_process(
CAT, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
) as proc:
pass
assert proc.returncode is not None
assert proc.stdin is not None
assert proc.stdout is not None
assert proc.stderr is not None
with pytest.raises(ClosedResourceError):
await proc.stdin.send_all(b"x")
with pytest.raises(ClosedResourceError):
await proc.stdout.receive_some()
with pytest.raises(ClosedResourceError):
await proc.stderr.receive_some()


# Test for deprecated 'async with process:' semantics
async def test_kill_when_context_cancelled(recwarn: pytest.WarningsRecorder) -> None:
with move_on_after(100) as scope:
async with await open_process(SLEEP(10)) as proc:
assert proc.poll() is None
scope.cancel()
await sleep_forever()
assert scope.cancelled_caught
assert got_signal(proc, SIGKILL)
assert repr(proc) == "<trio.Process {!r}: {}>".format(
SLEEP(10), "exited with signal 9" if posix else "exited with status 1"
)


COPY_STDIN_TO_STDOUT_AND_BACKWARD_TO_STDERR = python(
"data = sys.stdin.buffer.read(); "
"sys.stdout.buffer.write(data); "
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is imported from __init__.py and parsed by setuptools

__version__ = "0.23.2+dev"
__version__ = "0.24.0+dev"
40 changes: 0 additions & 40 deletions src/trio/tests.py

This file was deleted.

0 comments on commit 0547313

Please sign in to comment.