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

Function _generate_tokens_from_c_tokenizer

Lib/tokenize.py:581–594  ·  view source on GitHub ↗

Tokenize a source reading Python code as unicode strings using the internal C tokenizer

(source, encoding=None, extra_tokens=False)

Source from the content-addressed store, hash-verified

579 return msg
580
581def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False):
582 """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
583 if encoding is None:
584 it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
585 else:
586 it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
587 try:
588 for info in it:
589 yield TokenInfo._make(info)
590 except SyntaxError as e:
591 if type(e) != SyntaxError:
592 raise e from None
593 msg = _transform_msg(e.msg)
594 raise TokenError(msg, (e.lineno, e.offset)) from None
595
596
597if __name__ == "__main__":

Callers 3

tokenizeFunction · 0.85
generate_tokensFunction · 0.85
_mainFunction · 0.85

Calls 3

_transform_msgFunction · 0.85
TokenErrorClass · 0.85
_makeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…