Commit 7b92b6b
committed
asyncio: avoid sharing exception object between StreamReader and close waiter
StreamReaderProtocol.connection_lost() set the same exception object
on both the StreamReader's waiter and the Stream's _closed waiter.
Since gh-90082, Future stores the traceback at set_exception() time
and restores it with with_traceback() on every result() call, which
mutates the exception in place. Sharing one object between two
futures caused the second await (typically writer.wait_closed() in an
except block) to rewrite the traceback of the in-flight exception
being handled, erasing the real failure site (readexactly) and
replacing it with wait_closed frames.
Fix by copying the exception for the _closed waiter so each future
owns an independent object. Copy falls back to reconstructing via
type(exc)(*exc.args) when copy.copy fails.
Fixes #1562781 parent 43a1869 commit 7b92b6b
1 file changed
Lines changed: 24 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
283 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
284 | 307 | | |
285 | 308 | | |
286 | 309 | | |
| |||
0 commit comments