Skip to content

Commit 21fe071

Browse files
[7.4.x] fix for ValueError raised in faulthandler teardown code (#11455)
Co-authored-by: Simon Blanchard <[email protected]>
1 parent f8bb857 commit 21fe071

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ Serhii Mozghovyi
337337
Seth Junot
338338
Shantanu Jain
339339
Shubham Adep
340+
Simon Blanchard
340341
Simon Gomizelj
341342
Simon Holesch
342343
Simon Kerr

changelog/11439.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Handle an edge case where :data:`sys.stderr` might already be closed when :ref:`faulthandler` is tearing down.

src/_pytest/faulthandler.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import io
21
import os
32
import sys
43
from typing import Generator
@@ -51,7 +50,7 @@ def get_stderr_fileno() -> int:
5150
if fileno == -1:
5251
raise AttributeError()
5352
return fileno
54-
except (AttributeError, io.UnsupportedOperation):
53+
except (AttributeError, ValueError):
5554
# pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
5655
# https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
5756
# This is potentially dangerous, but the best we can do.

0 commit comments

Comments
 (0)