Skip to content

Commit 5d12066

Browse files
committed
handle strict_exception_groups=True by unwrapping user exceptions from within exceptiongroups
1 parent 6a004bb commit 5d12066

File tree

5 files changed

+137
-94
lines changed

5 files changed

+137
-94
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
os: [ubuntu-latest]
1515
# latest pylint/astroid doesn't support 3.7
1616
# python3.7 is covered in build_and_test_old_deps
17-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev']
17+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev']
1818

1919
steps:
2020
- uses: actions/checkout@v3

requirements-dev-full.txt

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.8
2+
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
5-
# pip-compile --output-file=requirements-dev-full.txt requirements-dev.in requirements-extras.in setup.py
5+
# pip-compile --output-file=requirements-dev-full.txt --resolver=backtracking requirements-dev.in requirements-extras.in setup.py
66
#
77
alabaster==0.7.13
88
# via sphinx
99
astroid==3.0.0
1010
# via pylint
11-
async-generator==1.10
12-
# via trio
1311
attrs==22.2.0
1412
# via
1513
# -r requirements-dev.in
@@ -30,21 +28,20 @@ charset-normalizer==3.1.0
3028
click==8.1.3
3129
# via pip-tools
3230
coverage[toml]==7.2.1
33-
# via pytest-cov
31+
# via
32+
# coverage
33+
# pytest-cov
3434
cryptography==39.0.2
35-
# via trustme
35+
# via
36+
# secretstorage
37+
# trustme
3638
dill==0.3.7
3739
# via pylint
3840
docutils==0.18.1
3941
# via
4042
# readme-renderer
4143
# sphinx
4244
# sphinx-rtd-theme
43-
exceptiongroup==1.1.3 ; python_version < "3.11"
44-
# via
45-
# pytest
46-
# trio
47-
# trio-websocket (setup.py)
4845
h11==0.14.0
4946
# via wsproto
5047
idna==3.4
@@ -57,16 +54,17 @@ imagesize==1.4.1
5754
importlib-metadata==6.0.0
5855
# via
5956
# keyring
60-
# sphinx
6157
# twine
62-
importlib-resources==6.1.0
63-
# via keyring
6458
iniconfig==2.0.0
6559
# via pytest
6660
isort==5.11.5
6761
# via pylint
6862
jaraco-classes==3.2.3
6963
# via keyring
64+
jeepney==0.8.0
65+
# via
66+
# keyring
67+
# secretstorage
7068
jinja2==3.1.2
7169
# via sphinx
7270
keyring==23.13.1
@@ -118,8 +116,6 @@ pytest-cov==4.0.0
118116
# via -r requirements-dev.in
119117
pytest-trio==0.8.0
120118
# via -r requirements-dev.in
121-
pytz==2023.3.post1
122-
# via babel
123119
readme-renderer==37.3
124120
# via twine
125121
requests==2.28.2
@@ -133,6 +129,8 @@ rfc3986==2.0.0
133129
# via twine
134130
rich==13.3.2
135131
# via twine
132+
secretstorage==3.3.3
133+
# via keyring
136134
six==1.16.0
137135
# via bleach
138136
sniffio==1.3.0
@@ -164,29 +162,16 @@ sphinxcontrib-serializinghtml==1.1.5
164162
# via sphinx
165163
sphinxcontrib-trio==1.1.2
166164
# via -r requirements-extras.in
167-
tomli==2.0.1
168-
# via
169-
# build
170-
# coverage
171-
# pip-tools
172-
# pylint
173-
# pyproject-hooks
174-
# pytest
175165
tomlkit==0.11.6
176166
# via pylint
177-
trio==0.22.0
167+
trio==0.24.0
178168
# via
179169
# pytest-trio
180170
# trio-websocket (setup.py)
181171
trustme==0.9.0
182172
# via -r requirements-dev.in
183173
twine==4.0.2
184174
# via -r requirements-extras.in
185-
typing-extensions==4.8.0
186-
# via
187-
# astroid
188-
# pylint
189-
# rich
190175
urllib3==1.26.15
191176
# via
192177
# requests
@@ -198,9 +183,7 @@ wheel==0.38.4
198183
wsproto==1.2.0
199184
# via trio-websocket (setup.py)
200185
zipp==3.15.0
201-
# via
202-
# importlib-metadata
203-
# importlib-resources
186+
# via importlib-metadata
204187

205188
# The following packages are considered to be unsafe in a requirements file:
206189
# pip

requirements-dev.txt

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,72 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.8
2+
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
5-
# pip-compile --output-file=requirements-dev.txt requirements-dev.in setup.py
5+
# pip-compile --output-file=requirements-dev.txt --resolver=backtracking requirements-dev.in setup.py
66
#
7-
async-generator==1.10
8-
# via trio
9-
attrs==22.2.0
7+
attrs==23.2.0
108
# via
119
# -r requirements-dev.in
1210
# outcome
1311
# trio
14-
build==0.10.0
12+
build==1.2.1
1513
# via pip-tools
16-
cffi==1.15.1
14+
cffi==1.16.0
1715
# via cryptography
18-
click==8.1.3
16+
click==8.1.7
1917
# via pip-tools
20-
coverage[toml]==7.2.1
21-
# via pytest-cov
22-
cryptography==41.0.4
23-
# via trustme
24-
exceptiongroup==1.1.3 ; python_version < "3.11"
18+
coverage[toml]==7.5.3
2519
# via
26-
# pytest
27-
# trio
28-
# trio-websocket (setup.py)
20+
# coverage
21+
# pytest-cov
22+
cryptography==42.0.8
23+
# via trustme
2924
h11==0.14.0
3025
# via wsproto
31-
idna==3.4
26+
idna==3.7
3227
# via
3328
# trio
3429
# trustme
3530
iniconfig==2.0.0
3631
# via pytest
37-
outcome==1.2.0
32+
outcome==1.3.0.post0
3833
# via
3934
# pytest-trio
4035
# trio
41-
packaging==23.0
36+
packaging==24.0
4237
# via
4338
# build
4439
# pytest
45-
pip-tools==6.14.0
40+
pip-tools==7.4.1
4641
# via -r requirements-dev.in
47-
pluggy==1.0.0
42+
pluggy==1.5.0
4843
# via pytest
49-
pycparser==2.21
44+
pycparser==2.22
5045
# via cffi
51-
pyproject-hooks==1.0.0
52-
# via build
53-
pytest==7.4.2
46+
pyproject-hooks==1.1.0
47+
# via
48+
# build
49+
# pip-tools
50+
pytest==8.2.2
5451
# via
5552
# -r requirements-dev.in
5653
# pytest-cov
5754
# pytest-trio
58-
pytest-cov==4.0.0
55+
pytest-cov==5.0.0
5956
# via -r requirements-dev.in
6057
pytest-trio==0.8.0
6158
# via -r requirements-dev.in
62-
sniffio==1.3.0
59+
sniffio==1.3.1
6360
# via trio
6461
sortedcontainers==2.4.0
6562
# via trio
66-
tomli==2.0.1
67-
# via
68-
# build
69-
# coverage
70-
# pip-tools
71-
# pyproject-hooks
72-
# pytest
73-
trio==0.22.0
63+
trio==0.25.1
7464
# via
7565
# pytest-trio
7666
# trio-websocket (setup.py)
77-
trustme==0.9.0
67+
trustme==1.1.0
7868
# via -r requirements-dev.in
79-
wheel==0.38.4
69+
wheel==0.43.0
8070
# via pip-tools
8171
wsproto==1.2.0
8272
# via trio-websocket (setup.py)

tests/test_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,15 @@ async def handler(request):
417417

418418

419419
@fail_after(1)
420-
async def test_handshake_exception_before_accept():
420+
async def test_handshake_exception_before_accept() -> None:
421421
''' In #107, a request handler that throws an exception before finishing the
422422
handshake causes the task to hang. The proper behavior is to raise an
423423
exception to the nursery as soon as possible. '''
424424
async def handler(request):
425425
raise ValueError()
426426

427-
with pytest.raises(ValueError):
428-
async with trio.open_nursery() as nursery:
427+
with trio.testing.RaisesGroup(ValueError, strict=False):
428+
async with trio.open_nursery(strict_exception_groups=True) as nursery:
429429
server = await nursery.start(serve_websocket, handler, HOST, 0,
430430
None)
431431
async with open_websocket(HOST, server.port, RESOURCE,

0 commit comments

Comments
 (0)