Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28ad12f

Browse files
authored
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 withextern) and rename functions:* PyST_GetScope() to _PyST_GetScope()* PySymtable_BuildObject() to _PySymtable_Build()* PySymtable_Free() to _PySymtable_Free()Remove PySymtable_Build(), Py_SymtableString() andPy_SymtableStringObject() functions.The Py_SymtableString() function was part the stable ABI by mistakebut it could not be used, since the symtable.h header file wasexcluded from the limited C API.The Python symtable module remains available and is unchanged.
1 parent32eba61 commit28ad12f

File tree

15 files changed

+100
-115
lines changed

15 files changed

+100
-115
lines changed

‎Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ Py_SetPath
776776
Py_SetProgramName
777777
Py_SetPythonHome
778778
Py_SetRecursionLimit
779-
Py_SymtableString
780779
Py_UTF8Mode
781780
Py_VaBuildValue
782781
Py_XNewRef

‎Doc/whatsnew/3.10.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,3 +1364,19 @@ Removed
13641364
ASTobject (``mod_ty``type)with the public CAPI. The function was already
13651365
excludedfrom the limited C API (:pep:`384`).
13661366
(Contributed by Victor Stinnerin :issue:`43244`.)
1367+
1368+
* Remove the``symtable.h`` headerfileand the undocumented functions:
1369+
1370+
*``PyST_GetScope()``
1371+
*``PySymtable_Build()``
1372+
*``PySymtable_BuildObject()``
1373+
*``PySymtable_Free()``
1374+
*``Py_SymtableString()``
1375+
*``Py_SymtableStringObject()``
1376+
1377+
The``Py_SymtableString()`` function was part the stableABI by mistake but
1378+
it couldnot be used, because the``symtable.h`` headerfile was excluded
1379+
from the limited CAPI.
1380+
1381+
The Python :mod:`symtable` module remains availableandis unchanged.
1382+
(Contributed by Victor Stinnerin :issue:`43244`.)

‎Include/cpython/pythonrun.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,6 @@ PyAPI_FUNC(const char *) _Py_SourceAsString(
7777
PyCompilerFlags*cf,
7878
PyObject**cmd_copy);
7979

80-
PyAPI_FUNC(structsymtable*)Py_SymtableStringObject(
81-
constchar*str,
82-
PyObject*filename,
83-
intstart);
84-
85-
PyAPI_FUNC(structsymtable*)_Py_SymtableStringObjectFlags(
86-
constchar*str,
87-
PyObject*filename,
88-
intstart,
89-
PyCompilerFlags*flags);
90-
9180

9281
/* A function flavor is also exported by libpython. It is required when
9382
libpython is accessed directly rather than using header files which defines

‎Include/symtable.hrenamed to‎Include/internal/pycore_symtable.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
#ifndefPy_LIMITED_API
2-
#ifndefPy_SYMTABLE_H
3-
#definePy_SYMTABLE_H
1+
#ifndefPy_INTERNAL_SYMTABLE_H
2+
#definePy_INTERNAL_SYMTABLE_H
43
#ifdef__cplusplus
54
extern"C" {
65
#endif
76

8-
#include"Python-ast.h"/* mod_ty */
7+
#ifndefPy_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
910

10-
/* XXX(ncoghlan): This is a weird mix of public names and interpreter internal
11-
* names.
12-
*/
11+
#include"Python-ast.h"/* mod_ty */
1312

1413
typedefenum_block_type {FunctionBlock,ClassBlock,ModuleBlock }
1514
_Py_block_ty;
@@ -68,23 +67,19 @@ typedef struct _symtable_entry {
6867
structsymtable*ste_table;
6968
}PySTEntryObject;
7069

71-
PyAPI_DATA(PyTypeObject)PySTEntry_Type;
70+
externPyTypeObjectPySTEntry_Type;
7271

7372
#definePySTEntry_Check(op) Py_IS_TYPE(op, &PySTEntry_Type)
7473

75-
PyAPI_FUNC(int)PyST_GetScope(PySTEntryObject*,PyObject*);
74+
externint_PyST_GetScope(PySTEntryObject*,PyObject*);
7675

77-
PyAPI_FUNC(structsymtable*)PySymtable_Build(
78-
mod_tymod,
79-
constchar*filename,/* decoded from the filesystem encoding */
80-
PyFutureFeatures*future);
81-
PyAPI_FUNC(structsymtable*)PySymtable_BuildObject(
76+
externstructsymtable*_PySymtable_Build(
8277
mod_tymod,
8378
PyObject*filename,
8479
PyFutureFeatures*future);
8580
PyAPI_FUNC(PySTEntryObject*)PySymtable_Lookup(structsymtable*,void*);
8681

87-
PyAPI_FUNC(void)PySymtable_Free(structsymtable*);
82+
externvoid_PySymtable_Free(structsymtable*);
8883

8984
/* Flags for def-use information */
9085

@@ -117,8 +112,14 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
117112
#defineGENERATOR 1
118113
#defineGENERATOR_EXPRESSION 2
119114

115+
// Used by symtablemodule.c
116+
externstructsymtable*_Py_SymtableStringObjectFlags(
117+
constchar*str,
118+
PyObject*filename,
119+
intstart,
120+
PyCompilerFlags*flags);
121+
120122
#ifdef__cplusplus
121123
}
122124
#endif
123-
#endif/* !Py_SYMTABLE_H */
124-
#endif/* !Py_LIMITED_API */
125+
#endif/* !Py_INTERNAL_SYMTABLE_H */

‎Include/pythonrun.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ extern "C" {
99

1010
PyAPI_FUNC(PyObject*)Py_CompileString(constchar*,constchar*,int);
1111

12-
PyAPI_FUNC(structsymtable*)Py_SymtableString(
13-
constchar*str,
14-
constchar*filename,/* decoded from the filesystem encoding */
15-
intstart);
16-
1712
PyAPI_FUNC(void)PyErr_Print(void);
1813
PyAPI_FUNC(void)PyErr_PrintEx(int);
1914
PyAPI_FUNC(void)PyErr_Display(PyObject*,PyObject*,PyObject*);

‎Makefile.pre.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,6 @@ PYTHON_HEADERS= \
10871087
$(srcdir)/Include/sliceobject.h \
10881088
$(srcdir)/Include/structmember.h \
10891089
$(srcdir)/Include/structseq.h \
1090-
$(srcdir)/Include/symtable.h \
10911090
$(srcdir)/Include/sysmodule.h \
10921091
$(srcdir)/Include/token.h \
10931092
$(srcdir)/Include/traceback.h \
@@ -1167,6 +1166,7 @@ PYTHON_HEADERS= \
11671166
$(srcdir)/Include/internal/pycore_pymem.h \
11681167
$(srcdir)/Include/internal/pycore_pystate.h \
11691168
$(srcdir)/Include/internal/pycore_runtime.h \
1169+
$(srcdir)/Include/internal/pycore_symtable.h \
11701170
$(srcdir)/Include/internal/pycore_sysmodule.h \
11711171
$(srcdir)/Include/internal/pycore_traceback.h \
11721172
$(srcdir)/Include/internal/pycore_tuple.h \
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Remove the ``symtable.h`` header file and the undocumented functions:
2+
3+
* ``PyST_GetScope()``
4+
* ``PySymtable_Build()``
5+
* ``PySymtable_BuildObject()``
6+
* ``PySymtable_Free()``
7+
* ``Py_SymtableString()``
8+
* ``Py_SymtableStringObject()``
9+
10+
The ``Py_SymtableString()`` function was part the stable ABI by mistake but it
11+
could not be used, because the ``symtable.h`` header file was excluded from the
12+
limited C API.
13+
14+
The Python:mod:`symtable` module remains available and is unchanged.
15+
16+
Patch by Victor Stinner.

‎Modules/symtablemodule.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include"Python.h"
22

3-
#include"code.h"
43
#include"Python-ast.h"
5-
#include"symtable.h"
4+
#include"pycore_symtable.h"// struct symtable
65

76
#include"clinic/symtablemodule.c.h"
87
/*[clinic input]
@@ -62,7 +61,7 @@ _symtable_symtable_impl(PyObject *module, PyObject *source,
6261
t= (PyObject*)st->st_top;
6362
Py_INCREF(t);
6463
PyMem_Free((void*)st->st_future);
65-
PySymtable_Free(st);
64+
_PySymtable_Free(st);
6665
returnt;
6766
}
6867

‎PC/python3dll.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ EXPORT_FUNC(Py_SetPath)
8080
EXPORT_FUNC(Py_SetProgramName)
8181
EXPORT_FUNC(Py_SetPythonHome)
8282
EXPORT_FUNC(Py_SetRecursionLimit)
83-
EXPORT_FUNC(Py_SymtableString)
8483
EXPORT_FUNC(Py_VaBuildValue)
8584
EXPORT_FUNC(Py_XNewRef)
8685
EXPORT_FUNC(PyArg_Parse)

‎PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
<ClIncludeInclude="..\Include\internal\pycore_pystate.h" />
209209
<ClIncludeInclude="..\Include\internal\pycore_runtime.h" />
210210
<ClIncludeInclude="..\Include\internal\pycore_sysmodule.h" />
211+
<ClIncludeInclude="..\Include\internal\pycore_symtable.h" />
211212
<ClIncludeInclude="..\Include\internal\pycore_traceback.h" />
212213
<ClIncludeInclude="..\Include\internal\pycore_tuple.h" />
213214
<ClIncludeInclude="..\Include\internal\pycore_ucnhash.h" />

‎PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@
585585
<ClIncludeInclude="..\Include\internal\pycore_sysmodule.h">
586586
<Filter>Include\internal</Filter>
587587
</ClInclude>
588+
<ClIncludeInclude="..\Include\internal\pycore_symtable.h">
589+
<Filter>Include\internal</Filter>
590+
</ClInclude>
588591
<ClIncludeInclude="..\Include\internal\pycore_traceback.h">
589592
<Filter>Include\internal</Filter>
590593
</ClInclude>

‎Python/compile.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include"pycore_ast.h"// _PyAST_GetDocString()
2626
#include"pycore_pymem.h"// _PyMem_IsPtrFreed()
2727
#include"pycore_long.h"// _PyLong_GetZero()
28+
#include"pycore_symtable.h"// PySTEntryObject
2829

29-
#include"symtable.h"// struct symtable
3030
#defineNEED_OPCODE_JUMP_TABLES
3131
#include"opcode.h"// EXTENDED_ARG
3232
#include"wordcode_helpers.h"// instrsize()
@@ -394,7 +394,7 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
394394
gotofinally;
395395
}
396396

397-
c.c_st=PySymtable_BuildObject(mod,filename,c.c_future);
397+
c.c_st=_PySymtable_Build(mod,filename,c.c_future);
398398
if (c.c_st==NULL) {
399399
if (!PyErr_Occurred())
400400
PyErr_SetString(PyExc_SystemError,"no symtable");
@@ -428,7 +428,7 @@ static void
428428
compiler_free(structcompiler*c)
429429
{
430430
if (c->c_st)
431-
PySymtable_Free(c->c_st);
431+
_PySymtable_Free(c->c_st);
432432
if (c->c_future)
433433
PyObject_Free(c->c_future);
434434
Py_XDECREF(c->c_filename);
@@ -729,7 +729,7 @@ compiler_set_qualname(struct compiler *c)
729729
mangled=_Py_Mangle(parent->u_private,u->u_name);
730730
if (!mangled)
731731
return0;
732-
scope=PyST_GetScope(parent->u_ste,mangled);
732+
scope=_PyST_GetScope(parent->u_ste,mangled);
733733
Py_DECREF(mangled);
734734
assert(scope!=GLOBAL_IMPLICIT);
735735
if (scope==GLOBAL_EXPLICIT)
@@ -1920,10 +1920,10 @@ get_ref_type(struct compiler *c, PyObject *name)
19201920
if (c->u->u_scope_type==COMPILER_SCOPE_CLASS&&
19211921
_PyUnicode_EqualToASCIIString(name,"__class__"))
19221922
returnCELL;
1923-
scope=PyST_GetScope(c->u->u_ste,name);
1923+
scope=_PyST_GetScope(c->u->u_ste,name);
19241924
if (scope==0) {
19251925
PyErr_Format(PyExc_SystemError,
1926-
"PyST_GetScope(name=%R) failed: "
1926+
"_PyST_GetScope(name=%R) failed: "
19271927
"unknown scope in unit %S (%R); "
19281928
"symbols: %R; locals: %R; globals: %R",
19291929
name,
@@ -3608,7 +3608,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
36083608

36093609
op=0;
36103610
optype=OP_NAME;
3611-
scope=PyST_GetScope(c->u->u_ste,mangled);
3611+
scope=_PyST_GetScope(c->u->u_ste,mangled);
36123612
switch (scope) {
36133613
caseFREE:
36143614
dict=c->u->u_freevars;

‎Python/pythonrun.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include"token.h"// INDENT
2424
#include"errcode.h"// E_EOF
2525
#include"code.h"// PyCodeObject
26-
#include"symtable.h"// PySymtable_BuildObject()
2726
#include"marshal.h"// PyMarshal_ReadLongFromFile()
2827

2928
#ifdefMS_WINDOWS
@@ -1369,48 +1368,6 @@ _Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyComp
13691368
returnstr;
13701369
}
13711370

1372-
structsymtable*
1373-
Py_SymtableStringObject(constchar*str,PyObject*filename,intstart)
1374-
{
1375-
PyCompilerFlagsflags=_PyCompilerFlags_INIT;
1376-
return_Py_SymtableStringObjectFlags(str,filename,start,&flags);
1377-
}
1378-
1379-
structsymtable*
1380-
_Py_SymtableStringObjectFlags(constchar*str,PyObject*filename,intstart,PyCompilerFlags*flags)
1381-
{
1382-
structsymtable*st;
1383-
mod_tymod;
1384-
PyArena*arena;
1385-
1386-
arena=PyArena_New();
1387-
if (arena==NULL)
1388-
returnNULL;
1389-
1390-
mod=PyParser_ASTFromStringObject(str,filename,start,flags,arena);
1391-
if (mod==NULL) {
1392-
PyArena_Free(arena);
1393-
returnNULL;
1394-
}
1395-
st=PySymtable_BuildObject(mod,filename,0);
1396-
PyArena_Free(arena);
1397-
returnst;
1398-
}
1399-
1400-
structsymtable*
1401-
Py_SymtableString(constchar*str,constchar*filename_str,intstart)
1402-
{
1403-
PyObject*filename;
1404-
structsymtable*st;
1405-
1406-
filename=PyUnicode_DecodeFSDefault(filename_str);
1407-
if (filename==NULL)
1408-
returnNULL;
1409-
st=Py_SymtableStringObject(str,filename,start);
1410-
Py_DECREF(filename);
1411-
returnst;
1412-
}
1413-
14141371
#if defined(USE_STACKCHECK)
14151372
#if defined(WIN32)&& defined(_MSC_VER)
14161373

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp