Skip to content

Commit e9cc92b

Browse files
authored
Merge pull request #34 from abraha2d/fix-windows-compat
Fix Windows compatibility
2 parents 0205b52 + 04accfe commit e9cc92b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/flupy/cli/cli.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
import importlib
33
import sys
4-
from signal import SIG_DFL, SIGPIPE, signal
54
from typing import Any, Dict, Generator, List, Optional
65

76
from flupy import __version__, flu, walk_dirs, walk_files
@@ -66,8 +65,14 @@ def main(argv: Optional[List[str]] = None) -> None:
6665
if _file:
6766
_ = flu(read_file(_file)).map(str.rstrip)
6867
else:
69-
# Do not raise exception for Broken Pipe
70-
signal(SIGPIPE, SIG_DFL)
68+
try:
69+
# Restore the default SIGPIPE handler
70+
from signal import SIG_DFL, SIGPIPE, signal
71+
signal(SIGPIPE, SIG_DFL)
72+
except ImportError:
73+
# SIGPIPE not available on platform (e.g. Windows), nothing to do
74+
pass
75+
7176
_ = flu(sys.stdin).map(str.rstrip)
7277

7378
locals_dict = {

0 commit comments

Comments
 (0)