diff options
author | Victor Stinner <vstinner@python.org> | 2021-03-24 00:29:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 00:29:09 (GMT) |
commit | 57364ce34e0492fbc8b0a6b8c882f384bb489457 (patch) | |
tree | d2679621c672fee40eb7e22ff79a8ea85830c3b3 /Tools | |
parent | a054f6b2b1d9f75edfb5ec2247bbf60f07491977 (diff) | |
download | cpython-57364ce34e0492fbc8b0a6b8c882f384bb489457.zip cpython-57364ce34e0492fbc8b0a6b8c882f384bb489457.tar.gz cpython-57364ce34e0492fbc8b0a6b8c882f384bb489457.tar.bz2 |
bpo-43244: Remove parser_interface.h header file (GH-25001)
Remove parser functions using the "struct _mod" type, because the
AST C API was removed:
* PyParser_ASTFromFile()
* PyParser_ASTFromFileObject()
* PyParser_ASTFromFilename()
* PyParser_ASTFromString()
* PyParser_ASTFromStringObject()
These functions were undocumented and excluded from the limited C
API.
Add pycore_parser.h internal header file. Rename functions:
* PyParser_ASTFromFileObject() => _PyParser_ASTFromFile()
* PyParser_ASTFromStringObject() => _PyParser_ASTFromString()
These functions are no longer exported (replace PyAPI_FUNC() with
extern).
Remove also _PyPegen_run_parser_from_file() function. Update
test_peg_generator to use _PyPegen_run_parser_from_file_pointer()
instead.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/peg_generator/peg_extension/peg_extension.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Tools/peg_generator/peg_extension/peg_extension.c b/Tools/peg_generator/peg_extension/peg_extension.c index f2a870e..209a34c 100644 --- a/Tools/peg_generator/peg_extension/peg_extension.c +++ b/Tools/peg_generator/peg_extension/peg_extension.c @@ -44,8 +44,17 @@ parse_file(PyObject *self, PyObject *args, PyObject *kwds) goto error; } + FILE *fp = fopen(filename, "rb"); + if (fp == NULL) { + PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename); + goto error; + } + PyCompilerFlags flags = _PyCompilerFlags_INIT; - mod_ty res = _PyPegen_run_parser_from_file(filename, Py_file_input, filename_ob, &flags, arena); + mod_ty res = _PyPegen_run_parser_from_file_pointer( + fp, Py_file_input, filename_ob, + NULL, NULL, NULL, &flags, NULL, arena); + fclose(fp); if (res == NULL) { goto error; } |