From c8118f92df0d0cac464c541cab4ad69e7deb113a Mon Sep 17 00:00:00 2001 From: AlberLC Date: Wed, 12 Jan 2022 22:25:55 +0100 Subject: [PATCH 1/2] Fix: Playwright fails if you suppress stderr (#1098) --- playwright/_impl/_transport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright/_impl/_transport.py b/playwright/_impl/_transport.py index 1b9ef4d8e..f8db1152e 100644 --- a/playwright/_impl/_transport.py +++ b/playwright/_impl/_transport.py @@ -35,7 +35,7 @@ def _get_stderr_fileno() -> Optional[int]: try: return sys.stderr.fileno() - except (AttributeError, io.UnsupportedOperation): + except (AttributeError, io.UnsupportedOperation, 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. From eb263728f6ce4ad8ee09b7dde6791afb48e9742a Mon Sep 17 00:00:00 2001 From: AlberLC Date: Thu, 13 Jan 2022 19:59:23 +0100 Subject: [PATCH 2/2] Fix: Check if stderr is closed (#1098) --- playwright/_impl/_transport.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/playwright/_impl/_transport.py b/playwright/_impl/_transport.py index f8db1152e..beae9569b 100644 --- a/playwright/_impl/_transport.py +++ b/playwright/_impl/_transport.py @@ -33,9 +33,12 @@ # Sourced from: https://github.com/pytest-dev/pytest/blob/da01ee0a4bb0af780167ecd228ab3ad249511302/src/_pytest/faulthandler.py#L69-L77 def _get_stderr_fileno() -> Optional[int]: + if sys.stderr.closed: + return None + try: return sys.stderr.fileno() - except (AttributeError, io.UnsupportedOperation, ValueError): + except (AttributeError, io.UnsupportedOperation): # 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.