From fc354f07855a9197e71f851ad930cbf5652f9160 Mon Sep 17 00:00:00 2001 From: Albert-Jan Nijburg Date: Wed, 31 May 2017 15:00:21 +0100 Subject: bpo-25324: copy tok_name before changing it (#1608) * add test to check if were modifying token * copy list so import tokenize doesnt have side effects on token * shorten line * add tokenize tokens to token.h to get them to show up in token * move ERRORTOKEN back to its previous location, and fix nitpick * copy comments from token.h automatically * fix whitespace and make more pythonic * change to fix comments from @haypo * update token.rst and Misc/NEWS * change wording * some more wording changes --- Lib/tokenize.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'Lib/tokenize.py') diff --git a/Lib/tokenize.py b/Lib/tokenize.py index 9017bb13e7..5fa4152609 100644 --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -38,17 +38,10 @@ cookie_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII) blank_re = re.compile(br'^[ \t\f]*(?:[#\r\n]|$)', re.ASCII) import token -__all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding", - "NL", "untokenize", "ENCODING", "TokenInfo"] +__all__ = token.__all__ + ["tokenize", "detect_encoding", + "untokenize", "TokenInfo"] del token -COMMENT = N_TOKENS -tok_name[COMMENT] = 'COMMENT' -NL = N_TOKENS + 1 -tok_name[NL] = 'NL' -ENCODING = N_TOKENS + 2 -tok_name[ENCODING] = 'ENCODING' -N_TOKENS += 3 EXACT_TOKEN_TYPES = { '(': LPAR, ')': RPAR, -- cgit v1.2.1