GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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.

Sign up for GitHub

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

Merged
vstinner merged 1 commit into python:master from vstinner:remove_ast_validate
Mar 18, 2021

Uh oh!

There was an error while loading. Please reload this page.

Merged

bpo-43244: Remove PyAST_Validate() function #24911

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
38ec882
bpo-43244: Remove the PyAST_Validate() function
vstinner Mar 17, 2021
File filter
Filter by extension

Clear filters
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
Diff view

There are no files selected for viewing

5 changes: 5 additions & 0 deletions 5 Doc/whatsnew/3.10.rst
Show comments
View file
Open in desktop
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

@shihai1991 shihai1991 Mar 18, 2021

Copy link
Copy Markdown
Member

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.

All reactions

@vstinner vstinner Mar 18, 2021

Copy link
Copy Markdown
Member Author

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.

All reactions

@vstinner vstinner Mar 18, 2021

Copy link
Copy Markdown
Member Author

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.

All reactions

@shihai1991 shihai1991 Mar 18, 2021

Copy link
Copy Markdown
Member

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.

OK, Thanks. got it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
(Contributed by Victor Stinner in :issue:`43244`.)
2 changes: 0 additions & 2 deletions 2 Include/ast.h
Show comments
View file
Open in desktop
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
2 changes: 2 additions & 0 deletions 2 Include/internal/pycore_ast.h
Show comments
View file
Open in desktop
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
3 changes: 3 additions & 0 deletions 3 Misc/NEWS.d/next/C API/2021-03-17-23-20-07.bpo-43244.diyn2C.rst
Show comments
View file
Open in desktop
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.
3 changes: 2 additions & 1 deletion 3 Parser/pegen.c
Show comments
View file
Open in desktop
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
2 changes: 1 addition & 1 deletion 2 Python/ast.c
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 Python/bltinmodule.c
Show comments
View file
Open in desktop
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.