Decode bytes representing source code and return the string. Universal newline support is used in the decoding.
(source_bytes)
| 530 | |
| 531 | |
| 532 | def decode_source(source_bytes): |
| 533 | """Decode bytes representing source code and return the string. |
| 534 | |
| 535 | Universal newline support is used in the decoding. |
| 536 | """ |
| 537 | import tokenize # To avoid bootstrap issues. |
| 538 | source_bytes_readline = _io.BytesIO(source_bytes).readline |
| 539 | encoding = tokenize.detect_encoding(source_bytes_readline) |
| 540 | return _io.TextIOWrapper(_io.BytesIO(source_bytes), encoding=encoding[0], newline=None).read() |
| 541 | |
| 542 | |
| 543 | # Module specifications ####################################################### |
no test coverage detected
searching dependent graphs…