mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Move a bunch of definitions that were internal to compile.c to
symtable.h, so that they can be used by external module. Improve error handling in symtable_enter_scope(), which return an error code that went unchecked by most callers. XXX The error handling in symtable code is sloppy in general. Modify symtable to record the line number that begins each scope. This can help to identify which code block is being referred to when multiple blocks are bound to the same name. Add st_scopes dict that is used to preserve scope info when PyNode_CompileSymtable() is called. Otherwise, this information is tossed as soon as it is no longer needed. Add Py_SymtableString() to pythonrun; analogous to Py_CompileString().
This commit is contained in:
parent
033f31270c
commit
4b38da664c
4 changed files with 210 additions and 116 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "parsetok.h"
|
||||
#include "errcode.h"
|
||||
#include "compile.h"
|
||||
#include "symtable.h"
|
||||
#include "eval.h"
|
||||
#include "marshal.h"
|
||||
|
||||
|
@ -963,6 +964,19 @@ Py_CompileString(char *str, char *filename, int start)
|
|||
return (PyObject *)co;
|
||||
}
|
||||
|
||||
struct symtable *
|
||||
Py_SymtableString(char *str, char *filename, int start)
|
||||
{
|
||||
node *n;
|
||||
struct symtable *st;
|
||||
n = PyParser_SimpleParseString(str, start);
|
||||
if (n == NULL)
|
||||
return NULL;
|
||||
st = PyNode_CompileSymtable(n, filename);
|
||||
PyNode_Free(n);
|
||||
return st;
|
||||
}
|
||||
|
||||
/* Simplified interface to parsefile -- return node or set exception */
|
||||
|
||||
node *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue