Handle ValueError raised during faulthandler teardown code (#11453)

Fixes #11439
This commit is contained in:
Simon Blanchard
2023-09-20 20:06:43 +08:00
committed by GitHub
parent 9f22d3281c
commit a38ad254ef
3 changed files with 3 additions and 2 deletions

View File

@@ -1,4 +1,3 @@
import io
import os
import sys
from typing import Generator
@@ -51,7 +50,7 @@ def get_stderr_fileno() -> int:
if fileno == -1:
raise AttributeError()
return fileno
except (AttributeError, io.UnsupportedOperation):
except (AttributeError, ValueError):
# 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
# This is potentially dangerous, but the best we can do.