mirror of
https://github.com/python/cpython.git
synced 2025-10-28 01:00:34 +00:00
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
simplifies a lot of error handling code, and fixes many memory leaks.
This commit is contained in:
parent
23a6958910
commit
adb69fcdff
16 changed files with 704 additions and 1242 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "Python.h"
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "pyarena.h"
|
||||
#include "pythonrun.h"
|
||||
#include "errcode.h"
|
||||
#include "marshal.h"
|
||||
|
|
@ -773,13 +774,14 @@ parse_source_module(const char *pathname, FILE *fp)
|
|||
{
|
||||
PyCodeObject *co = NULL;
|
||||
mod_ty mod;
|
||||
PyArena *arena = PyArena_New();
|
||||
|
||||
mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0,
|
||||
NULL);
|
||||
NULL, arena);
|
||||
if (mod) {
|
||||
co = PyAST_Compile(mod, pathname, NULL);
|
||||
free_mod(mod);
|
||||
co = PyAST_Compile(mod, pathname, NULL, arena);
|
||||
}
|
||||
PyArena_Free(arena);
|
||||
return co;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue