From ea16d16c0a4af59ea9eb033af7a424ae2e639a53 Mon Sep 17 00:00:00 2001 From: Simon Blanchard Date: Tue, 19 Sep 2023 19:19:50 +0200 Subject: [PATCH] fix for ValueError raised in faulthandler teardown code Fixes https://github.com/pytest-dev/pytest/issues/11439 --- AUTHORS | 1 + changelog/11439.bugfix.rst | 1 + src/_pytest/faulthandler.py | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog/11439.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 16918b40c06..606039f6093 100644 --- a/AUTHORS +++ b/AUTHORS @@ -346,6 +346,7 @@ Serhii Mozghovyi Seth Junot Shantanu Jain Shubham Adep +Simon Blanchard Simon Gomizelj Simon Holesch Simon Kerr diff --git a/changelog/11439.bugfix.rst b/changelog/11439.bugfix.rst new file mode 100644 index 00000000000..9ddc26ecbe4 --- /dev/null +++ b/changelog/11439.bugfix.rst @@ -0,0 +1 @@ +Fix for ValueError exception being raised in faulthandler teardown code. diff --git a/src/_pytest/faulthandler.py b/src/_pytest/faulthandler.py index 2dc672c8d7f..a9418f34e11 100644 --- a/src/_pytest/faulthandler.py +++ b/src/_pytest/faulthandler.py @@ -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.