Open a file in read only mode using the encoding detected by detect_encoding().
(filename)
| 455 | |
| 456 | |
| 457 | def open(filename): |
| 458 | """Open a file in read only mode using the encoding detected by |
| 459 | detect_encoding(). |
| 460 | """ |
| 461 | buffer = _builtin_open(filename, 'rb') |
| 462 | try: |
| 463 | encoding, lines = detect_encoding(buffer.readline) |
| 464 | buffer.seek(0) |
| 465 | text = TextIOWrapper(buffer, encoding, line_buffering=True) |
| 466 | text.mode = 'r' |
| 467 | return text |
| 468 | except: |
| 469 | buffer.close() |
| 470 | raise |
| 471 | |
| 472 | def tokenize(readline): |
| 473 | """ |
nothing calls this directly
no test coverage detected
searching dependent graphs…