diff options
author | Marta Gómez Macías <mgmacias@google.com> | 2023-05-21 00:03:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-21 00:03:02 (GMT) |
commit | 6715f91edcf6f379f666e18f57b8a0dcb724bf79 (patch) | |
tree | 25724d6eb5b8ff5e713f7bfd8f6c33e5a6d87f62 /Lib/inspect.py | |
parent | 3ed57e4995d9f8583083483f397ddc3131720953 (diff) | |
download | cpython-6715f91edcf6f379f666e18f57b8a0dcb724bf79.zip cpython-6715f91edcf6f379f666e18f57b8a0dcb724bf79.tar.gz cpython-6715f91edcf6f379f666e18f57b8a0dcb724bf79.tar.bz2 |
gh-102856: Python tokenizer implementation for PEP 701 (#104323)
This commit replaces the Python implementation of the tokenize module with an implementation
that reuses the real C tokenizer via a private extension module. The tokenize module now implements
a compatibility layer that transforms tokens from the C tokenizer into Python tokenize tokens for backward
compatibility.
As the C tokenizer does not emit some tokens that the Python tokenizer provides (such as comments and non-semantic newlines), a new special mode has been added to the C tokenizer mode that currently is only used via
the extension module that exposes it to the Python layer. This new mode forces the C tokenizer to emit these new extra tokens and add the appropriate metadata that is needed to match the old Python implementation.
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 63f5aa9..7709a95 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2187,7 +2187,7 @@ def _signature_strip_non_python_syntax(signature): if string == ',': current_parameter += 1 - if (type == ERRORTOKEN) and (string == '$'): + if (type == OP) and (string == '$'): assert self_parameter is None self_parameter = current_parameter continue @@ -2195,7 +2195,7 @@ def _signature_strip_non_python_syntax(signature): add(string) if (string == ','): add(' ') - clean_signature = ''.join(text) + clean_signature = ''.join(text).strip() return clean_signature, self_parameter |