summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-06-07 19:36:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-06-07 19:36:39 (GMT)
commitc41616230211822e838634b84b445f8a124add08 (patch)
treee6b7fdd58675a3e0e5957dea0ad159168c5371db /Parser
parent024b2f52bf76358eea62f0206ea32c1ca518fde3 (diff)
downloadcpython-c41616230211822e838634b84b445f8a124add08.zip
cpython-c41616230211822e838634b84b445f8a124add08.tar.gz
cpython-c41616230211822e838634b84b445f8a124add08.tar.bz2
allow the keyword else immediately after (no space) an integer (closes #21642)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 7283058..22accd1 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1597,15 +1597,24 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
} while (isdigit(c));
}
if (c == 'e' || c == 'E') {
- exponent:
+ int e;
+ exponent:
+ e = c;
/* Exponent part */
c = tok_nextc(tok);
- if (c == '+' || c == '-')
+ if (c == '+' || c == '-') {
c = tok_nextc(tok);
- if (!isdigit(c)) {
- tok->done = E_TOKEN;
+ if (!isdigit(c)) {
+ tok->done = E_TOKEN;
+ tok_backup(tok, c);
+ return ERRORTOKEN;
+ }
+ } else if (!isdigit(c)) {
tok_backup(tok, c);
- return ERRORTOKEN;
+ tok_backup(tok, e);
+ *p_start = tok->start;
+ *p_end = tok->cur;
+ return NUMBER;
}
do {
c = tok_nextc(tok);