diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-05-01 17:30:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 17:30:51 (GMT) |
commit | 03b7642265e65f198682f22648dbe6cf4fff9835 (patch) | |
tree | 9eb424f013229729e2eef40ec91de43f69983027 /Include | |
parent | d9d6eadf003605f4cdb55e38df2168dd1bc0dbd5 (diff) | |
download | cpython-03b7642265e65f198682f22648dbe6cf4fff9835.zip cpython-03b7642265e65f198682f22648dbe6cf4fff9835.tar.gz cpython-03b7642265e65f198682f22648dbe6cf4fff9835.tar.bz2 |
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`.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pegen_interface.h | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/Include/internal/pegen_interface.h b/Include/internal/pegen_interface.h index adff731..ee4c77e 100644 --- a/Include/internal/pegen_interface.h +++ b/Include/internal/pegen_interface.h @@ -11,25 +11,34 @@ extern "C" { #include "Python.h" #include "Python-ast.h" -PyAPI_FUNC(mod_ty) PyPegen_ASTFromFile(const char *filename, int mode, PyCompilerFlags*, PyArena *arena); -PyAPI_FUNC(mod_ty) PyPegen_ASTFromString(const char *str, int mode, PyCompilerFlags *flags, - PyArena *arena); -PyAPI_FUNC(mod_ty) PyPegen_ASTFromStringObject(const char *str, PyObject* filename, int mode, - PyCompilerFlags *flags, PyArena *arena); -PyAPI_FUNC(mod_ty) PyPegen_ASTFromFileObject(FILE *fp, PyObject *filename_ob, - int mode, const char *enc, const char *ps1, - const char *ps2, PyCompilerFlags *flags, - int *errcode, PyArena *arena); -PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromFile(const char *filename, int mode, PyCompilerFlags *flags); -PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromString(const char *str, int mode, - PyCompilerFlags *flags); -PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromFileObject(FILE *, PyObject *filename_ob, - int mode, - const char *ps1, - const char *ps2, - PyCompilerFlags *flags, - const char *enc, - int *errcode); +PyAPI_FUNC(mod_ty) PyPegen_ASTFromString( + const char *str, + const char *filename, + int mode, + PyCompilerFlags *flags, + PyArena *arena); +PyAPI_FUNC(mod_ty) PyPegen_ASTFromStringObject( + const char *str, + PyObject* filename, + int mode, + PyCompilerFlags *flags, + PyArena *arena); +PyAPI_FUNC(mod_ty) PyPegen_ASTFromFileObject( + FILE *fp, + PyObject *filename_ob, + int mode, + const char *enc, + const char *ps1, + const char *ps2, + PyCompilerFlags *flags, + int *errcode, + PyArena *arena); +PyAPI_FUNC(mod_ty) PyPegen_ASTFromFilename( + const char *filename, + int mode, + PyCompilerFlags *flags, + PyArena *arena); + #ifdef __cplusplus } |