MCPcopy Index your code
hub / github.com/python/cpython / decode_source

Function decode_source

Lib/importlib/_bootstrap_external.py:532–540  ·  view source on GitHub ↗

Decode bytes representing source code and return the string. Universal newline support is used in the decoding.

(source_bytes)

Source from the content-addressed store, hash-verified

530
531
532def 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 #######################################################

Callers 1

get_sourceMethod · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…