summaryrefslogtreecommitdiff
blob: e0678d105363ce7060641b8ead4c6edad9bd9f77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
commit e43ef015ae88c43fa39274a23515adbe22ba2b2a
Author: Ilya Tumaykin <itumaykin@gmail.com>
Date:   Tue May 10 08:06:13 2016 +0300

options: fix StrOptType for non-interactive shells on Python 2

Closes: https://github.com/guessit-io/guessit/issues/293
---

diff --git a/guessit/options.py b/guessit/options.py
index 3d60ef9..41ba143 100644
--- a/guessit/options.py
+++ b/guessit/options.py
@@ -11,7 +11,7 @@ import six


 if six.PY2:
-    StrOptType = lambda s: unicode(s, sys.stdin.encoding)  # pylint:disable=undefined-variable
+    StrOptType = lambda s: unicode(s, sys.stdin.encoding) if sys.stdin.isatty() else unicode(s, 'UTF-8')  # pylint:disable=undefined-variable
 else:
     StrOptType = str  # pylint:disable=redefined-variable-type