mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
Issue #26331: Implement the parsing part of PEP 515.
Thanks to Georg Brandl for the patch.
This commit is contained in:
parent
ee73a65745
commit
a721abac29
22 changed files with 743 additions and 205 deletions
27
Python/ast.c
27
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;
|
||||
|
@ -4060,6 +4060,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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue