Skip to content

Commit 129c2fe

Browse files
committed
Handle closed standard input gracefully
For: #26
1 parent 5607d7b commit 129c2fe

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

usr/lib/python3/dist-packages/stdisplay/stcat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def main() -> None:
1616
"""Safely print stdin or file to stdout."""
1717
# https://github.com/pytest-dev/pytest/issues/4843
18-
if "pytest" not in modules:
18+
if "pytest" not in modules and stdin is not None:
1919
stdin.reconfigure(errors="ignore") # type: ignore
2020
## File input reads stdin when no file is provided or file is '-'.
2121
for untrusted_text in file_input(encoding="ascii", errors="replace"):

usr/lib/python3/dist-packages/stdisplay/stcatn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main() -> None:
2020
main
2121
"""
2222
# https://github.com/pytest-dev/pytest/issues/4843
23-
if "pytest" not in modules:
23+
if "pytest" not in modules and stdin is not None:
2424
stdin.reconfigure(errors="ignore") # type: ignore
2525

2626
for line in file_input(encoding="ascii", errors="replace"):

usr/lib/python3/dist-packages/stdisplay/stsponge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def main() -> None:
1717
"""Safely print stdin to stdout or file."""
1818
# https://github.com/pytest-dev/pytest/issues/4843
19-
if "pytest" not in modules:
19+
if "pytest" not in modules and stdin is not None:
2020
stdin.reconfigure(errors="ignore") # type: ignore
2121
untrusted_text_list = []
2222
for untrusted_text in stdin:

usr/lib/python3/dist-packages/stdisplay/sttee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def main() -> None:
1414
"""Safely print stdin to stdout and file."""
1515
# https://github.com/pytest-dev/pytest/issues/4843
16-
if "pytest" not in modules:
16+
if "pytest" not in modules and stdin is not None:
1717
stdin.reconfigure(errors="ignore") # type: ignore
1818
untrusted_text_list = []
1919
for untrusted_text in stdin:

0 commit comments

Comments
 (0)