mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-35879: Fix type comment leaks (GH-11728)
* Fix leak for # type: ignore * Fix the type comment leak
This commit is contained in:
parent
ac19081c26
commit
d2b4c19d53
2 changed files with 9 additions and 3 deletions
11
Python/ast.c
11
Python/ast.c
|
@ -699,11 +699,16 @@ ast_error(struct compiling *c, const node *n, const char *errmsg, ...)
|
|||
*/
|
||||
|
||||
static string
|
||||
new_type_comment(const char *s)
|
||||
new_type_comment(const char *s, struct compiling *c)
|
||||
{
|
||||
return PyUnicode_DecodeUTF8(s, strlen(s), NULL);
|
||||
PyObject *res = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
|
||||
if (PyArena_AddPyObject(c->c_arena, res) < 0) {
|
||||
Py_DECREF(res);
|
||||
return NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#define NEW_TYPE_COMMENT(n) new_type_comment(STR(n))
|
||||
#define NEW_TYPE_COMMENT(n) new_type_comment(STR(n), c)
|
||||
|
||||
static int
|
||||
num_stmts(const node *n)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue