[7.4.x] fix for ValueError raised in faulthandler teardown code (#11455) · pytest-dev/pytest@21fe071 (original) (raw)
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -337,6 +337,7 @@ Serhii Mozghovyi | ||
337 | 337 | Seth Junot |
338 | 338 | Shantanu Jain |
339 | 339 | Shubham Adep |
340 | +Simon Blanchard | |
340 | 341 | Simon Gomizelj |
341 | 342 | Simon Holesch |
342 | 343 | Simon Kerr |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 | +Handle an edge case where :data:`sys.stderr` might already be closed when :ref:`faulthandler` is tearing down. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
1 | -import io | |
2 | 1 | import os |
3 | 2 | import sys |
4 | 3 | from typing import Generator |
@@ -51,7 +50,7 @@ def get_stderr_fileno() -> int: | ||
51 | 50 | if fileno == -1: |
52 | 51 | raise AttributeError() |
53 | 52 | return fileno |
54 | -except (AttributeError, io.UnsupportedOperation): | |
53 | +except (AttributeError, ValueError): | |
55 | 54 | # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file. |
56 | 55 | # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors |
57 | 56 | # This is potentially dangerous, but the best we can do. |