bpo-40334: Make the PyPegen* and PyParser* APIs more consistent (GH-19839)
This commit makes both APIs more consistent by doing the following:
- Remove the `PyPegen_CodeObjectFrom*` functions, which weren't used
and will probably not be needed. Functions like `Py_CompileStringObject`
can be used instead.
- Include a `const char *filename` parameter in `PyPegen_ASTFromString`.
- Rename `PyPegen_ASTFromFile` to `PyPegen_ASTFromFilename`, because
its signature is not the same with `PyParser_ASTFromFile`.
diff --git a/Modules/_peg_parser.c b/Modules/_peg_parser.c
index 59b80f9..3b27b2c 100644
--- a/Modules/_peg_parser.c
+++ b/Modules/_peg_parser.c
@@ -31,7 +31,7 @@
PyCompilerFlags flags = _PyCompilerFlags_INIT;
PyObject *result = NULL;
- mod_ty res = PyPegen_ASTFromFile(filename, mode, &flags, arena);
+ mod_ty res = PyPegen_ASTFromFilename(filename, mode, &flags, arena);
if (res == NULL) {
goto error;
}
@@ -84,7 +84,7 @@
res = PyParser_ASTFromString(the_string, "<string>", mode, &flags, arena);
}
else {
- res = PyPegen_ASTFromString(the_string, mode, &flags, arena);
+ res = PyPegen_ASTFromString(the_string, "<string>", mode, &flags, arena);
}
if (res == NULL) {
goto error;