Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 16421:aa844711463a legacy-trunk
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().
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Fri, 02 Feb 2001 18:19:15 +0000 |
| parents | 8c41f3861aad |
| children | e8e636cc1a09 |
comparison
equal
deleted
inserted
replaced
| 16420:38204093d9c9 | 16421:aa844711463a |
|---|---|
| 7 #include "node.h" | 7 #include "node.h" |
| 8 #include "token.h" | 8 #include "token.h" |
| 9 #include "parsetok.h" | 9 #include "parsetok.h" |
| 10 #include "errcode.h" | 10 #include "errcode.h" |
| 11 #include "compile.h" | 11 #include "compile.h" |
| 12 #include "symtable.h" | |
| 12 #include "eval.h" | 13 #include "eval.h" |
| 13 #include "marshal.h" | 14 #include "marshal.h" |
| 14 | 15 |
| 15 #ifdef HAVE_UNISTD_H | 16 #ifdef HAVE_UNISTD_H |
| 16 #include <unistd.h> | 17 #include <unistd.h> |
| 961 co = PyNode_Compile(n, filename); | 962 co = PyNode_Compile(n, filename); |
| 962 PyNode_Free(n); | 963 PyNode_Free(n); |
| 963 return (PyObject *)co; | 964 return (PyObject *)co; |
| 964 } | 965 } |
| 965 | 966 |
| 967 struct symtable * | |
| 968 Py_SymtableString(char *str, char *filename, int start) | |
| 969 { | |
| 970 node *n; | |
| 971 struct symtable *st; | |
| 972 n = PyParser_SimpleParseString(str, start); | |
| 973 if (n == NULL) | |
| 974 return NULL; | |
| 975 st = PyNode_CompileSymtable(n, filename); | |
| 976 PyNode_Free(n); | |
| 977 return st; | |
| 978 } | |
| 979 | |
| 966 /* Simplified interface to parsefile -- return node or set exception */ | 980 /* Simplified interface to parsefile -- return node or set exception */ |
| 967 | 981 |
| 968 node * | 982 node * |
| 969 PyParser_SimpleParseFile(FILE *fp, char *filename, int start) | 983 PyParser_SimpleParseFile(FILE *fp, char *filename, int start) |
| 970 { | 984 { |
