STINNER Victor <victor.stin...@haypocalc.com> added the comment:

> Leaving open to discuss whether anything can/should be done
> for the case when reindent acts as an stdin

sys.stdin.buffer and sys.stdout.buffer should be used with 
tokenize.detect_encoding(). We may read first stdin and write it into a BytesIO 
object to be able to rewind after detect_encoding. Something like:

content = sys.stdin.buffer.read()
raw = io.BytesIO(content)
buffer = io.BufferedReader(raw)
encoding, _ = detect_encoding(buffer.readline)
buffer.seek(0)
text = TextIOWrapper(buffer, encoding)
# use text

----------
nosy: +haypo

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10117>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to