GeezerVison is showing github.com — bpo-43244: Remove PyAST_Validate() function by vstinner · Pull Request #24911 · python/cpython
bpo-43244: Remove PyAST_Validate() function
#24911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.c
(3)
.h
(2)
.rst
(2)
All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1353,3 +1353,8 @@ Removed
Python already implicitly installs signal handlers: see
:c:member:`PyConfig.install_signal_handlers`.
(Contributed by Victor Stinner in :issue:`41713`.)
* Remove the ``PyAST_Validate()`` function. It is no longer possible to build a
AST object (``mod_ty`` type) with the public C API. The function was already
excluded from the limited C API (:pep:`384`).
Comment thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Hm, pep-384 doesn't mention the ast.h. Can we move the capi directly when this C API is not a limited C API?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
I just mentioned PEP 384 to explain what is the limited C API.
PyAST_Validate() definition is inside:
#ifndef Py_LIMITED_API
...
#endif /* !Py_LIMITED_API */
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
"Can we move the capi directly when this C API is not a limited C API?" No. I only removed the function since it cannot be used anymore since Python 3.10: " It is no longer possible to build a AST object (mod_ty type) with the public C API."
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
(Contributed by Victor Stinner in :issue:`43244`.)
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,8 +7,6 @@ extern "C" {
#include "Python-ast.h" /* mod_ty */
PyAPI_FUNC(int) PyAST_Validate(mod_ty);
#ifdef __cplusplus
}
#endif
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -10,6 +10,8 @@ extern "C" {
#include "Python-ast.h" // expr_ty
extern int _PyAST_Validate(mod_ty);
/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
extern PyObject* _PyAST_ExprAsUnicode(expr_ty);
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,3 @@
Remove the ``PyAST_Validate()`` function. It is no longer possible to build a
AST object (``mod_ty`` type) with the public C API. The function was already
excluded from the limited C API (:pep:`384`). Patch by Victor Stinner.
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
#include <Python.h>
#include "pycore_ast.h" // _PyAST_Validate()
#include <errcode.h>
#include "tokenizer.h"
Expand Down
Expand Up
@@ -1271,7 +1272,7 @@ _PyPegen_run_parser(Parser *p)
p->start_rule == Py_file_input ||
p->start_rule == Py_eval_input)
{
if (!PyAST_Validate (res)) {
if (!_PyAST_Validate (res)) {
return NULL;
}
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -551,7 +551,7 @@ validate_exprs(asdl_expr_seq *exprs, expr_context_ty ctx, int null_ok)
}
int
PyAST_Validate (mod_ty mod)
_PyAST_Validate (mod_ty mod)
{
int res = 0;
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -4,6 +4,7 @@
#include <ctype.h>
#include "ast.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
#include "pycore_ast.h" // _PyAST_Validate()
#include "pycore_object.h" // _Py_AddToAllObjects()
#include "pycore_pyerrors.h" // _PyErr_NoMemory()
#include "pycore_pystate.h" // _PyThreadState_GET()
Expand Down
Expand Up
@@ -835,7 +836,7 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
PyArena_Free(arena);
goto error;
}
if (!PyAST_Validate (mod)) {
if (!_PyAST_Validate (mod)) {
PyArena_Free(arena);
goto error;
}
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.