gh-135801: Add the module parameter to compile() etc (GH-139652)
Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code() now allow to pass the module name used when filtering syntax warnings.
This commit is contained in:
@@ -43,6 +43,7 @@ _PyTokenizer_tok_new(void)
|
||||
tok->encoding = NULL;
|
||||
tok->cont_line = 0;
|
||||
tok->filename = NULL;
|
||||
tok->module = NULL;
|
||||
tok->decoding_readline = NULL;
|
||||
tok->decoding_buffer = NULL;
|
||||
tok->readline = NULL;
|
||||
@@ -91,6 +92,7 @@ _PyTokenizer_Free(struct tok_state *tok)
|
||||
Py_XDECREF(tok->decoding_buffer);
|
||||
Py_XDECREF(tok->readline);
|
||||
Py_XDECREF(tok->filename);
|
||||
Py_XDECREF(tok->module);
|
||||
if ((tok->readline != NULL || tok->fp != NULL ) && tok->buf != NULL) {
|
||||
PyMem_Free(tok->buf);
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ struct tok_state {
|
||||
int parenlinenostack[MAXLEVEL];
|
||||
int parencolstack[MAXLEVEL];
|
||||
PyObject *filename;
|
||||
PyObject *module;
|
||||
/* Stuff for checking on different tab sizes */
|
||||
int altindstack[MAXINDENT]; /* Stack of alternate indents */
|
||||
/* Stuff for PEP 0263 */
|
||||
|
||||
Reference in New Issue
Block a user