bpo-43244: Remove symtable.h header file (GH-24910)

Rename Include/symtable.h to to Include/internal/pycore_symtable.h,
don't export symbols anymore (replace PyAPI_FUNC and PyAPI_DATA with
extern) and rename functions:

* PyST_GetScope() to _PyST_GetScope()
* PySymtable_BuildObject() to _PySymtable_Build()
* PySymtable_Free() to _PySymtable_Free()

Remove PySymtable_Build(), Py_SymtableString() and
Py_SymtableStringObject() functions.

The Py_SymtableString() function was part the stable ABI by mistake
but it could not be used, since the symtable.h header file was
excluded from the limited C API.

The Python symtable module remains available and is unchanged.
This commit is contained in:
Victor Stinner 2021-03-19 12:41:49 +01:00 committed by GitHub
parent 32eba61ea4
commit 28ad12f8fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 100 additions and 115 deletions

View file

@ -25,8 +25,8 @@
#include "pycore_ast.h" // _PyAST_GetDocString()
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_symtable.h" // PySTEntryObject
#include "symtable.h" // struct symtable
#define NEED_OPCODE_JUMP_TABLES
#include "opcode.h" // EXTENDED_ARG
#include "wordcode_helpers.h" // instrsize()
@ -394,7 +394,7 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
goto finally;
}
c.c_st = PySymtable_BuildObject(mod, filename, c.c_future);
c.c_st = _PySymtable_Build(mod, filename, c.c_future);
if (c.c_st == NULL) {
if (!PyErr_Occurred())
PyErr_SetString(PyExc_SystemError, "no symtable");
@ -428,7 +428,7 @@ static void
compiler_free(struct compiler *c)
{
if (c->c_st)
PySymtable_Free(c->c_st);
_PySymtable_Free(c->c_st);
if (c->c_future)
PyObject_Free(c->c_future);
Py_XDECREF(c->c_filename);
@ -729,7 +729,7 @@ compiler_set_qualname(struct compiler *c)
mangled = _Py_Mangle(parent->u_private, u->u_name);
if (!mangled)
return 0;
scope = PyST_GetScope(parent->u_ste, mangled);
scope = _PyST_GetScope(parent->u_ste, mangled);
Py_DECREF(mangled);
assert(scope != GLOBAL_IMPLICIT);
if (scope == GLOBAL_EXPLICIT)
@ -1920,10 +1920,10 @@ get_ref_type(struct compiler *c, PyObject *name)
if (c->u->u_scope_type == COMPILER_SCOPE_CLASS &&
_PyUnicode_EqualToASCIIString(name, "__class__"))
return CELL;
scope = PyST_GetScope(c->u->u_ste, name);
scope = _PyST_GetScope(c->u->u_ste, name);
if (scope == 0) {
PyErr_Format(PyExc_SystemError,
"PyST_GetScope(name=%R) failed: "
"_PyST_GetScope(name=%R) failed: "
"unknown scope in unit %S (%R); "
"symbols: %R; locals: %R; globals: %R",
name,
@ -3608,7 +3608,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
op = 0;
optype = OP_NAME;
scope = PyST_GetScope(c->u->u_ste, mangled);
scope = _PyST_GetScope(c->u->u_ste, mangled);
switch (scope) {
case FREE:
dict = c->u->u_freevars;