Skip to content

Commit 3cb3bac

Browse files
mickmccmxschmitt
andauthored
fix: handle pyinstaller app with no stderr (#1148) (#1154)
Co-authored-by: Max Schmitt <max@schmitt.mx>
1 parent ab954ac commit 3cb3bac

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

playwright/_impl/_transport.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@
3434

3535
# Sourced from: https://github.com/pytest-dev/pytest/blob/da01ee0a4bb0af780167ecd228ab3ad249511302/src/_pytest/faulthandler.py#L69-L77
3636
def _get_stderr_fileno() -> Optional[int]:
37-
if sys.stderr.closed:
38-
return None
39-
4037
try:
38+
# when using pythonw, sys.stderr is None.
39+
# when Pyinstaller is used, there is no closed attribute because Pyinstaller monkey-patches it with a NullWriter class
40+
if sys.stderr is None or not hasattr(sys.stderr, "closed"):
41+
return None
42+
if sys.stderr.closed:
43+
return None
44+
4145
return sys.stderr.fileno()
4246
except (AttributeError, io.UnsupportedOperation):
4347
# pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.

0 commit comments

Comments
 (0)