diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-10 01:14:38 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-10 01:14:38 +0300 |
commit | 142aee3a8e49375d405d8696f15f538f104ab78d (patch) | |
tree | a1961d66e2a42db428c2b9502e681f480ee1288b /Python/ast.c | |
parent | be9a4e5c855188cf146962483e6de942bf154d95 (diff) | |
parent | d8fdffedaa71a260d59ff67400d49be4643b90f0 (diff) | |
download | cpython-git-142aee3a8e49375d405d8696f15f538f104ab78d.tar.gz |
Merge heads
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c index 37193329c8..dcaa697a38 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -4018,7 +4018,7 @@ ast_for_stmt(struct compiling *c, const node *n) } static PyObject * -parsenumber(struct compiling *c, const char *s) +parsenumber_raw(struct compiling *c, const char *s) { const char *end; long x; @@ -4061,6 +4061,31 @@ parsenumber(struct compiling *c, const char *s) } static PyObject * +parsenumber(struct compiling *c, const char *s) +{ + char *dup, *end; + PyObject *res = NULL; + + assert(s != NULL); + + if (strchr(s, '_') == NULL) { + return parsenumber_raw(c, s); + } + /* Create a duplicate without underscores. */ + dup = PyMem_Malloc(strlen(s) + 1); + end = dup; + for (; *s; s++) { + if (*s != '_') { + *end++ = *s; + } + } + *end = '\0'; + res = parsenumber_raw(c, dup); + PyMem_Free(dup); + return res; +} + +static PyObject * decode_utf8(struct compiling *c, const char **sPtr, const char *end) { const char *s, *t; |