Skip to content

Commit b948e2c

Browse files
committed
fix #82, test for sys.stdin
1 parent 37fa297 commit b948e2c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nameparser/config/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ def add_with_encoding(self, s, encoding=None):
9292
explicit `encoding` parameter to specify the encoding of binary strings that
9393
are not DEFAULT_ENCODING (UTF-8).
9494
"""
95-
encoding = encoding or sys.stdin.encoding or DEFAULT_ENCODING
95+
stdin_encoding = None
96+
if sys.stdin:
97+
stdin_encoding = sys.stdin.encoding
98+
encoding = encoding or stdin_encoding or DEFAULT_ENCODING
9699
if type(s) == binary_type:
97100
s = s.decode(encoding)
98101
self.elements.add(lc(s))

0 commit comments

Comments
 (0)