@@ -35,36 +35,18 @@ class BrokenStdoutLoggingError(Exception):
35
35
Raised if BrokenPipeError occurs for the stdout stream while logging.
36
36
"""
37
37
38
- pass
39
38
39
+ def _is_broken_pipe_error (exc_class : Type [BaseException ], exc : BaseException ) -> bool :
40
+ if exc_class is BrokenPipeError :
41
+ return True
40
42
41
- # BrokenPipeError manifests differently in Windows and non-Windows.
42
- if WINDOWS :
43
- # In Windows, a broken pipe can show up as EINVAL rather than EPIPE:
43
+ # On Windows, a broken pipe can show up as EINVAL rather than EPIPE:
44
44
# https://bugs.python.org/issue19612
45
45
# https://bugs.python.org/issue30418
46
- def _is_broken_pipe_error (
47
- exc_class : Type [BaseException ], exc : BaseException
48
- ) -> bool :
49
- """See the docstring for non-Windows below."""
50
- return (exc_class is BrokenPipeError ) or (
51
- isinstance (exc , OSError ) and exc .errno in (errno .EINVAL , errno .EPIPE )
52
- )
53
-
54
-
55
- else :
56
- # Then we are in the non-Windows case.
57
- def _is_broken_pipe_error (
58
- exc_class : Type [BaseException ], exc : BaseException
59
- ) -> bool :
60
- """
61
- Return whether an exception is a broken pipe error.
46
+ if not WINDOWS :
47
+ return False
62
48
63
- Args:
64
- exc_class: an exception class.
65
- exc: an exception instance.
66
- """
67
- return exc_class is BrokenPipeError
49
+ return isinstance (exc , OSError ) and exc .errno in (errno .EINVAL , errno .EPIPE )
68
50
69
51
70
52
@contextlib .contextmanager
0 commit comments