[7.4.x] fix for ValueError raised in faulthandler teardown code (#11455)

Co-authored-by: Simon Blanchard <bnomis@gmail.com>
This commit is contained in:
github-actions[bot] 2023-09-20 12:41:01 +00:00 committed by GitHub
parent f8bb8572fe
commit 21fe071d79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -337,6 +337,7 @@ Serhii Mozghovyi
Seth Junot Seth Junot
Shantanu Jain Shantanu Jain
Shubham Adep Shubham Adep
Simon Blanchard
Simon Gomizelj Simon Gomizelj
Simon Holesch Simon Holesch
Simon Kerr Simon Kerr

View File

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

View File

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