gh-99300: Use Py_NewRef() in Parser/ directory (#99330)
Replace Py_INCREF() with Py_NewRef() in C files of the Parser/ directory and in the PEG generator.
This commit is contained in:
parent
1e197e63e2
commit
4ce2a202c7
@ -885,8 +885,7 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena
|
|||||||
tok->fp_interactive = 1;
|
tok->fp_interactive = 1;
|
||||||
}
|
}
|
||||||
// This transfers the ownership to the tokenizer
|
// This transfers the ownership to the tokenizer
|
||||||
tok->filename = filename_ob;
|
tok->filename = Py_NewRef(filename_ob);
|
||||||
Py_INCREF(filename_ob);
|
|
||||||
|
|
||||||
// From here on we need to clean up even if there's an error
|
// From here on we need to clean up even if there's an error
|
||||||
mod_ty result = NULL;
|
mod_ty result = NULL;
|
||||||
@ -925,8 +924,7 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// This transfers the ownership to the tokenizer
|
// This transfers the ownership to the tokenizer
|
||||||
tok->filename = filename_ob;
|
tok->filename = Py_NewRef(filename_ob);
|
||||||
Py_INCREF(filename_ob);
|
|
||||||
|
|
||||||
// We need to clear up from here on
|
// We need to clear up from here on
|
||||||
mod_ty result = NULL;
|
mod_ty result = NULL;
|
||||||
|
@ -417,9 +417,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
|
|||||||
PyMem_Free(str);
|
PyMem_Free(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(p->tok->filename);
|
tok->filename = Py_NewRef(p->tok->filename);
|
||||||
|
|
||||||
tok->filename = p->tok->filename;
|
|
||||||
tok->lineno = t->lineno + lines - 1;
|
tok->lineno = t->lineno + lines - 1;
|
||||||
|
|
||||||
Parser *p2 = _PyPegen_Parser_New(tok, Py_fstring_input, p->flags, p->feature_version,
|
Parser *p2 = _PyPegen_Parser_New(tok, Py_fstring_input, p->flags, p->feature_version,
|
||||||
|
@ -2223,8 +2223,7 @@ _PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
Py_INCREF(filename);
|
tok->filename = Py_NewRef(filename);
|
||||||
tok->filename = filename;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tok->filename = PyUnicode_FromString("<string>");
|
tok->filename = PyUnicode_FromString("<string>");
|
||||||
|
@ -12,8 +12,7 @@ _build_return_object(mod_ty module, int mode, PyObject *filename_ob, PyArena *ar
|
|||||||
} else if (mode == 1) {
|
} else if (mode == 1) {
|
||||||
result = PyAST_mod2obj(module);
|
result = PyAST_mod2obj(module);
|
||||||
} else {
|
} else {
|
||||||
result = Py_None;
|
result = Py_NewRef(Py_None);
|
||||||
Py_INCREF(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user