Open a file in read only mode using the encoding detected by detect_encoding().
(filename)
| 390 | |
| 391 | |
| 392 | def open(filename): |
| 393 | """Open a file in read only mode using the encoding detected by |
| 394 | detect_encoding(). |
| 395 | """ |
| 396 | buffer = _builtin_open(filename, 'rb') |
| 397 | try: |
| 398 | encoding, lines = detect_encoding(buffer.readline) |
| 399 | buffer.seek(0) |
| 400 | text = TextIOWrapper(buffer, encoding, line_buffering=True) |
| 401 | text.mode = 'r' |
| 402 | return text |
| 403 | except: |
| 404 | buffer.close() |
| 405 | raise |
| 406 | |
| 407 | |
| 408 | def tokenize(readline): |
nothing calls this directly
no test coverage detected