diff options
| author | Tomaz Solc <tomaz.solc@tablix.org> | 2015-05-13 18:21:03 +0200 |
|---|---|---|
| committer | Tomaz Solc <tomaz.solc@tablix.org> | 2015-05-13 18:21:03 +0200 |
| commit | 2d41919dde5822fc39ec44e75e3d1cf30994af65 (patch) | |
| tree | 162e4533884fe8c5acf7ccc2ce313023407bf5c8 /unidecode | |
| parent | 8090157dab6284471634a2ca5535b7d0ede03ead (diff) | |
| download | unidecode-2d41919dde5822fc39ec44e75e3d1cf30994af65.tar.gz | |
Avoid reopening sys.stdin on Python 3.
Diffstat (limited to 'unidecode')
| -rw-r--r-- | unidecode/util.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/unidecode/util.py b/unidecode/util.py index b47869a..cad13a3 100644 --- a/unidecode/util.py +++ b/unidecode/util.py @@ -32,11 +32,10 @@ def main(): with open(args.file, 'rb') as f: stream = f.read() else: - # In Python 3, stdin.read() is read in the system's locale and returns type str - # This returns bytes on Python 3 and str on Python 2 - f = os.fdopen(sys.stdin.fileno(), 'rb') - stream = f.read() - f.close() + if PY3: + stream = sys.stdin.buffer.read() + else: + stream = sys.stdin.read() try: stream = stream.decode(encoding) |
