Message139967
| Author |
vstinner |
| Recipients |
belopolsky, christian.heimes, eric.araujo, flox, georg.brandl, tim.peters, vstinner |
| Date |
2011年07月07日.10:50:00 |
| SpamBayes Score |
0.00095128187 |
| Marked as misclassified |
No |
| Message-id |
<1310035801.78.0.438007040732.issue10117@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> 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 |
|