Repository navigation
Commit 594e4f5
fix: guard FDCapture.snap() against prematurely closed tmpfile (pytest-dev#14528)
Under Python 3.14's incremental garbage collector (present in 3.14.0–3.14.4,
reverted in 3.14.5), the TemporaryFile backing FDCapture can be finalized
before pytest's own capture teardown runs. This caused a ValueError crash
in stop_global_capturing and corrupted the exit code.
Guard snap() in both FDCapture and FDCaptureBinary to return EMPTY_BUFFER
when the tmpfile is already closed, with a PytestWarning so the lost capture
is discoverable. The captured data is lost anyway, so crashing on teardown
only makes things worse.
Upstream references:
- Incremental GC tracking issue: python/cpython#108362
- Memory pressure reports: python/cpython#142516
- Revert (forward-port generational GC to 3.14): python/cpython#148720
- Revert discussion: https://discuss.python.org/t/107014
Closes pytest-dev#14528
Co-authored-by: Cursor AI <ai@cursor.sh>
Co-authored-by: Claude Opus 4 <claude@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 2f26a02 commit 594e4f5
3 files changed
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
566 | 568 | | |
567 | 569 | | |
568 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
569 | 582 | | |
570 | 583 | | |
571 | 584 | | |
| |||
588 | 601 | | |
589 | 602 | | |
590 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
591 | 615 | | |
592 | 616 | | |
593 | 617 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1129 | 1129 | | |
1130 | 1130 | | |
1131 | 1131 | | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1132 | 1166 | | |
1133 | 1167 | | |
1134 | 1168 | | |
| |||
0 commit comments