]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127303: Add docs for token.EXACT_TOKEN_TYPES (#127304)
authorИлья Любавский <100635212+lubaskinc0de@users.noreply.github.com>
Fri, 29 Nov 2024 09:00:50 +0000 (12:00 +0300)
committerGitHub <noreply@github.com>
Fri, 29 Nov 2024 09:00:50 +0000 (04:00 -0500)
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Doc/library/token.rst
Lib/token.py
Misc/ACKS
Misc/NEWS.d/next/Library/2024-11-27-16-06-10.gh-issue-127303.asqkgh.rst [new file with mode: 0644]
Tools/build/generate_token.py

index 0cc9dddd91ed6b5e99517d634f7cc08d6e014b2a..40982f32b4beeebb62bc3097c304f753c36e5875 100644 (file)
@@ -79,6 +79,13 @@ the :mod:`tokenize` module.
    ``type_comments=True``.
 
 
+.. data:: EXACT_TOKEN_TYPES
+
+   A dictionary mapping the string representation of a token to its numeric code.
+
+   .. versionadded:: 3.8
+
+
 .. versionchanged:: 3.5
    Added :data:`!AWAIT` and :data:`!ASYNC` tokens.
 
index b620317106e173163ec5fcdcb3ca396c71f2b752..54d7cdccadc79a5e126d1d4b4c56c13599eb133f 100644 (file)
@@ -1,7 +1,8 @@
 """Token constants."""
 # Auto-generated by Tools/build/generate_token.py
 
-__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
+__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF',
+           'EXACT_TOKEN_TYPES']
 
 ENDMARKER = 0
 NAME = 1
index 08cd293eac38358b41b6d6c0cd00d5037045131a..cd34846574b3041422ffe4eb8c3141cd25c305e6 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1154,6 +1154,7 @@ Mark Lutz
 Taras Lyapun
 Jim Lynch
 Mikael Lyngvig
+Ilya Lyubavski
 Jeff MacDonald
 John Machin
 Andrew I MacIntyre
diff --git a/Misc/NEWS.d/next/Library/2024-11-27-16-06-10.gh-issue-127303.asqkgh.rst b/Misc/NEWS.d/next/Library/2024-11-27-16-06-10.gh-issue-127303.asqkgh.rst
new file mode 100644 (file)
index 0000000..58ebf5d
--- /dev/null
@@ -0,0 +1 @@
+Publicly expose :data:`~token.EXACT_TOKEN_TYPES` in :attr:`!token.__all__`.
index 16c38841e44a4dbd5630373a2d5e2f9d297edb71..d32747f19945d84ab2486f95966626cf8ea873db 100755 (executable)
@@ -226,7 +226,8 @@ token_py_template = f'''\
 # {AUTO_GENERATED_BY_SCRIPT}
 '''
 token_py_template += '''
-__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
+__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF',
+           'EXACT_TOKEN_TYPES']
 
 %s
 N_TOKENS = %d