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

Commite45cb02

Browse files
committed
gh-106320: Create pycore_modsupport.h header file (#106355)
Remove the following functions from the C API, move them to the internal CAPI: add a new pycore_modsupport.h internal header file:* PyModule_CreateInitialized()* _PyArg_NoKwnames()* _Py_VaBuildStack()No longer export these functions.
1 parent5ccbbe5 commite45cb02

28 files changed

+117
-62
lines changed

‎Include/cpython/modsupport.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ PyAPI_FUNC(int) _PyArg_UnpackStack(
1111
...);
1212

1313
PyAPI_FUNC(int)_PyArg_NoKeywords(constchar*funcname,PyObject*kwargs);
14-
PyAPI_FUNC(int)_PyArg_NoKwnames(constchar*funcname,PyObject*kwnames);
1514
PyAPI_FUNC(int)_PyArg_NoPositional(constchar*funcname,PyObject*args);
1615
#define_PyArg_NoKeywords(funcname,kwargs) \
1716
((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs)))
18-
#define_PyArg_NoKwnames(funcname,kwnames) \
19-
((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
2017
#define_PyArg_NoPositional(funcname,args) \
2118
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
2219

@@ -29,13 +26,6 @@ PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
2926
((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \
3027
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
3128

32-
PyAPI_FUNC(PyObject**)_Py_VaBuildStack(
33-
PyObject**small_stack,
34-
Py_ssize_tsmall_stack_len,
35-
constchar*format,
36-
va_listva,
37-
Py_ssize_t*p_nargs);
38-
3929
typedefstruct_PyArg_Parser {
4030
intinitialized;
4131
constchar*format;
@@ -83,5 +73,3 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg(
8373
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
8474
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
8575
(minpos), (maxpos), (minkw), (buf)))
86-
87-
PyAPI_FUNC(PyObject*)_PyModule_CreateInitialized(PyModuleDef*,intapiver);

‎Include/cpython/pyerrors.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,21 @@ typedef PyOSErrorObject PyWindowsErrorObject;
9191
/* Error handling definitions */
9292

9393
PyAPI_FUNC(void)_PyErr_SetKeyError(PyObject*);
94-
PyAPI_FUNC(_PyErr_StackItem*)_PyErr_GetTopmostException(PyThreadState*tstate);
95-
PyAPI_FUNC(PyObject*)_PyErr_GetHandledException(PyThreadState*);
96-
PyAPI_FUNC(void)_PyErr_SetHandledException(PyThreadState*,PyObject*);
97-
PyAPI_FUNC(void)_PyErr_GetExcInfo(PyThreadState*,PyObject**,PyObject**,PyObject**);
9894

9995
/* Context manipulation (PEP 3134) */
10096

10197
Py_DEPRECATED(3.12)PyAPI_FUNC(void)_PyErr_ChainExceptions(PyObject*,PyObject*,PyObject*);
10298
PyAPI_FUNC(void)_PyErr_ChainExceptions1(PyObject*);
10399

104-
/* Like PyErr_Format(), but saves current exception as __context__ and
105-
__cause__.
106-
*/
107-
PyAPI_FUNC(PyObject*)_PyErr_FormatFromCause(
108-
PyObject*exception,
109-
constchar*format,/* ASCII-encoded string */
110-
...
111-
);
112-
113100
/* In exceptions.c */
114101

115-
PyAPI_FUNC(int)_PyException_AddNote(
116-
PyObject*exc,
117-
PyObject*note);
118-
119102
PyAPI_FUNC(PyObject*)PyUnstable_Exc_PrepReraiseStar(
120103
PyObject*orig,
121104
PyObject*excs);
122105

123106
/* In signalmodule.c */
124107

125108
intPySignal_SetWakeupFd(intfd);
126-
PyAPI_FUNC(int)_PyErr_CheckSignals(void);
127109

128110
/* Support for adding program text to SyntaxErrors */
129111

@@ -143,18 +125,6 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
143125
PyObject*filename,
144126
intlineno);
145127

146-
PyAPI_FUNC(PyObject*)_PyErr_ProgramDecodedTextObject(
147-
PyObject*filename,
148-
intlineno,
149-
constchar*encoding);
150-
151-
PyAPI_FUNC(PyObject*)_PyUnicodeTranslateError_Create(
152-
PyObject*object,
153-
Py_ssize_tstart,
154-
Py_ssize_tend,
155-
constchar*reason/* UTF-8 encoded string */
156-
);
157-
158128
PyAPI_FUNC(void)_PyErr_WriteUnraisableMsg(
159129
constchar*err_msg,
160130
PyObject*obj);
@@ -163,16 +133,4 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFunc(
163133
constchar*func,
164134
constchar*message);
165135

166-
PyAPI_FUNC(void)_Py_NO_RETURN_Py_FatalErrorFormat(
167-
constchar*func,
168-
constchar*format,
169-
...);
170-
171-
externPyObject*_PyErr_SetImportErrorWithNameFrom(
172-
PyObject*,
173-
PyObject*,
174-
PyObject*,
175-
PyObject*);
176-
177-
178136
#definePy_FatalError(message) _Py_FatalErrorFunc(__func__, (message))

‎Include/internal/pycore_modsupport.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndefPy_INTERNAL_MODSUPPORT_H
2+
#definePy_INTERNAL_MODSUPPORT_H
3+
#ifdef__cplusplus
4+
extern"C" {
5+
#endif
6+
7+
#ifndefPy_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
12+
externint_PyArg_NoKwnames(constchar*funcname,PyObject*kwnames);
13+
#define_PyArg_NoKwnames(funcname,kwnames) \
14+
((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
15+
16+
externPyObject**_Py_VaBuildStack(
17+
PyObject**small_stack,
18+
Py_ssize_tsmall_stack_len,
19+
constchar*format,
20+
va_listva,
21+
Py_ssize_t*p_nargs);
22+
23+
externPyObject*_PyModule_CreateInitialized(PyModuleDef*,intapiver);
24+
25+
#ifdef__cplusplus
26+
}
27+
#endif
28+
#endif// !Py_INTERNAL_MODSUPPORT_H
29+

‎Include/internal/pycore_pyerrors.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,54 @@ extern "C" {
99
#endif
1010

1111

12+
/* Error handling definitions */
13+
14+
PyAPI_FUNC(_PyErr_StackItem*)_PyErr_GetTopmostException(PyThreadState*tstate);
15+
PyAPI_FUNC(PyObject*)_PyErr_GetHandledException(PyThreadState*);
16+
PyAPI_FUNC(void)_PyErr_SetHandledException(PyThreadState*,PyObject*);
17+
PyAPI_FUNC(void)_PyErr_GetExcInfo(PyThreadState*,PyObject**,PyObject**,PyObject**);
18+
19+
/* Like PyErr_Format(), but saves current exception as __context__ and
20+
__cause__.
21+
*/
22+
PyAPI_FUNC(PyObject*)_PyErr_FormatFromCause(
23+
PyObject*exception,
24+
constchar*format,/* ASCII-encoded string */
25+
...
26+
);
27+
28+
PyAPI_FUNC(int)_PyException_AddNote(
29+
PyObject*exc,
30+
PyObject*note);
31+
32+
PyAPI_FUNC(int)_PyErr_CheckSignals(void);
33+
34+
/* Support for adding program text to SyntaxErrors */
35+
36+
PyAPI_FUNC(PyObject*)_PyErr_ProgramDecodedTextObject(
37+
PyObject*filename,
38+
intlineno,
39+
constchar*encoding);
40+
41+
PyAPI_FUNC(PyObject*)_PyUnicodeTranslateError_Create(
42+
PyObject*object,
43+
Py_ssize_tstart,
44+
Py_ssize_tend,
45+
constchar*reason/* UTF-8 encoded string */
46+
);
47+
48+
PyAPI_FUNC(void)_Py_NO_RETURN_Py_FatalErrorFormat(
49+
constchar*func,
50+
constchar*format,
51+
...);
52+
53+
externPyObject*_PyErr_SetImportErrorWithNameFrom(
54+
PyObject*,
55+
PyObject*,
56+
PyObject*,
57+
PyObject*);
58+
59+
1260
/* runtime lifecycle */
1361

1462
externPyStatus_PyErr_InitTypes(PyInterpreterState*);

‎Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,7 @@ PYTHON_HEADERS= \
17611761
$(srcdir)/Include/internal/pycore_intrinsics.h \
17621762
$(srcdir)/Include/internal/pycore_list.h \
17631763
$(srcdir)/Include/internal/pycore_long.h \
1764+
$(srcdir)/Include/internal/pycore_modsupport.h \
17641765
$(srcdir)/Include/internal/pycore_moduleobject.h \
17651766
$(srcdir)/Include/internal/pycore_namespace.h \
17661767
$(srcdir)/Include/internal/pycore_object.h \

‎Modules/_io/bufferedio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include"Python.h"
1111
#include"pycore_call.h"// _PyObject_CallNoArgs()
1212
#include"pycore_object.h"
13+
#include"pycore_pyerrors.h"// _Py_FatalErrorFormat()
1314
#include"structmember.h"// PyMemberDef
1415
#include"_iomodule.h"
1516

‎Modules/_operator.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include"Python.h"
2+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
23
#include"pycore_moduleobject.h"// _PyModule_GetState()
3-
#include"structmember.h"// PyMemberDef
44
#include"pycore_runtime.h"// _Py_ID()
5+
6+
#include"structmember.h"// PyMemberDef
57
#include"clinic/_operator.c.h"
68

79
typedefstruct {

‎Modules/_sqlite/cursor.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@
2121
* 3. This notice may not be removed or altered from any source distribution.
2222
*/
2323

24+
#ifndefPy_BUILD_CORE_BUILTIN
25+
# definePy_BUILD_CORE_MODULE 1
26+
#endif
27+
2428
#include"cursor.h"
2529
#include"microprotocols.h"
2630
#include"module.h"
2731
#include"util.h"
2832

33+
#include"pycore_pyerrors.h"// _PyErr_FormatFromCause()
34+
2935
typedefenum {
3036
TYPE_LONG,
3137
TYPE_FLOAT,

‎Objects/boolobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* Boolean type, a subtype of int */
22

33
#include"Python.h"
4-
#include"pycore_object.h"// _Py_FatalRefcountError()
5-
#include"pycore_long.h"// FALSE_TAG TRUE_TAG
4+
#include"pycore_long.h"// FALSE_TAG TRUE_TAG
5+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
6+
#include"pycore_object.h"// _Py_FatalRefcountError()
67
#include"pycore_runtime.h"// _Py_ID()
78

89
#include<stddef.h>

‎Objects/call.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include"pycore_call.h"// _PyObject_CallNoArgsTstate()
33
#include"pycore_ceval.h"// _Py_EnterRecursiveCallTstate()
44
#include"pycore_dict.h"// _PyDict_FromItems()
5+
#include"pycore_modsupport.h"// _Py_VaBuildStack()
56
#include"pycore_object.h"// _PyCFunctionWithKeywords_TrampolineCall()
67
#include"pycore_pyerrors.h"// _PyErr_Occurred()
78
#include"pycore_pystate.h"// _PyThreadState_GET()

‎Objects/enumobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include"Python.h"
44
#include"pycore_call.h"// _PyObject_CallNoArgs()
55
#include"pycore_long.h"// _PyLong_GetOne()
6+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
67
#include"pycore_object.h"// _PyObject_GC_TRACK()
78

89
#include"clinic/enumobject.c.h"

‎Objects/floatobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include"pycore_initconfig.h"// _PyStatus_OK()
1010
#include"pycore_interp.h"// _PyInterpreterState.float_state
1111
#include"pycore_long.h"// _PyLong_GetOne()
12+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
1213
#include"pycore_object.h"// _PyObject_Init()
1314
#include"pycore_pymath.h"// _PY_SHORT_FLOAT_REPR
1415
#include"pycore_pystate.h"// _PyInterpreterState_GET()

‎Objects/listobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include"pycore_interp.h"// PyInterpreterState.list
66
#include"pycore_list.h"// struct _Py_list_state, _PyListIterObject
77
#include"pycore_long.h"// _PyLong_DigitCount
8+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
89
#include"pycore_object.h"// _PyObject_GC_TRACK()
910
#include"pycore_tuple.h"// _PyTuple_FromArray()
1011
#include<stddef.h>

‎Objects/moduleobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include"Python.h"
55
#include"pycore_call.h"// _PyObject_CallNoArgs()
66
#include"pycore_interp.h"// PyInterpreterState.importlib
7+
#include"pycore_modsupport.h"// _PyModule_CreateInitialized()
8+
#include"pycore_moduleobject.h"// _PyModule_GetDef()
79
#include"pycore_object.h"// _PyType_AllocNoTrack
10+
#include"pycore_pyerrors.h"// _PyErr_FormatFromCause()
811
#include"pycore_pystate.h"// _PyInterpreterState_GET()
9-
#include"pycore_moduleobject.h"// _PyModule_GetDef()
1012
#include"structmember.h"// PyMemberDef
1113

1214

‎Objects/obmalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
#include"Python.h"
44
#include"pycore_code.h"// stats
5-
#include"pycore_pystate.h"// _PyInterpreterState_GET
6-
75
#include"pycore_obmalloc.h"
6+
#include"pycore_pyerrors.h"// _Py_FatalErrorFormat()
87
#include"pycore_pymem.h"
8+
#include"pycore_pystate.h"// _PyInterpreterState_GET
99

1010
#include<stdlib.h>// malloc()
1111
#include<stdbool.h>

‎Objects/rangeobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
#include"Python.h"
44
#include"pycore_abstract.h"// _PyIndex_Check()
5-
#include"pycore_range.h"
65
#include"pycore_long.h"// _PyLong_GetZero()
6+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
7+
#include"pycore_range.h"
78
#include"pycore_tuple.h"// _PyTuple_ITEMS()
89
#include"structmember.h"// PyMemberDef
910

‎Objects/setobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
#include"Python.h"
35+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
3536
#include"pycore_object.h"// _PyObject_GC_UNTRACK()
3637
#include<stddef.h>// offsetof()
3738

‎Objects/tupleobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include"pycore_abstract.h"// _PyIndex_Check()
66
#include"pycore_gc.h"// _PyObject_GC_IS_TRACKED()
77
#include"pycore_initconfig.h"// _PyStatus_OK()
8+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
89
#include"pycore_object.h"// _PyObject_GC_TRACK(), _Py_FatalRefcountError()
910

1011
/*[clinic input]

‎Objects/typeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include"pycore_frame.h"// _PyInterpreterFrame
99
#include"pycore_long.h"// _PyLong_IsNegative()
1010
#include"pycore_memoryobject.h"// _PyMemoryView_FromBufferProc()
11+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
1112
#include"pycore_moduleobject.h"// _PyModule_GetDef()
1213
#include"pycore_object.h"// _PyType_HasFeature()
1314
#include"pycore_pyerrors.h"// _PyErr_Occurred()

‎Objects/unicodeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5050
#include"pycore_long.h"// _PyLong_FormatWriter()
5151
#include"pycore_object.h"// _PyObject_GC_TRACK(), _Py_FatalRefcountError()
5252
#include"pycore_pathconfig.h"// _Py_DumpPathConfig()
53+
#include"pycore_pyerrors.h"// _PyUnicodeTranslateError_Create()
5354
#include"pycore_pylifecycle.h"// _Py_SetFileSystemEncoding()
5455
#include"pycore_pystate.h"// _PyInterpreterState_GET()
5556
#include"pycore_ucnhash.h"// _PyUnicode_Name_CAPI

‎Objects/weakrefobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include"Python.h"
2+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
23
#include"pycore_object.h"// _PyObject_GET_WEAKREFS_LISTPTR()
34
#include"pycore_weakref.h"// _PyWeakref_GET_REF()
45
#include"structmember.h"// PyMemberDef

‎PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
<ClIncludeInclude="..\Include\internal\pycore_intrinsics.h" />
242242
<ClIncludeInclude="..\Include\internal\pycore_list.h" />
243243
<ClIncludeInclude="..\Include\internal\pycore_long.h" />
244+
<ClIncludeInclude="..\Include\internal\pycore_modsupport.h" />
244245
<ClIncludeInclude="..\Include\internal\pycore_moduleobject.h" />
245246
<ClIncludeInclude="..\Include\internal\pycore_namespace.h" />
246247
<ClIncludeInclude="..\Include\internal\pycore_object.h" />

‎PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@
627627
<ClIncludeInclude="..\Include\internal\pycore_long.h">
628628
<Filter>Include\internal</Filter>
629629
</ClInclude>
630+
<ClIncludeInclude="..\Include\internal\pycore_modsupport.h">
631+
<Filter>Include\internal</Filter>
632+
</ClInclude>
630633
<ClIncludeInclude="..\Include\internal\pycore_moduleobject.h">
631634
<Filter>Include\internal</Filter>
632635
</ClInclude>

‎Parser/pegen_errors.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include<Python.h>
22
#include<errcode.h>
33

4+
#include"pycore_pyerrors.h"// _PyErr_ProgramDecodedTextObject()
45
#include"tokenizer.h"
56
#include"pegen.h"
67

‎Python/bltinmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
#include<ctype.h>
55
#include"pycore_ast.h"// _PyAST_Validate()
66
#include"pycore_call.h"// _PyObject_CallNoArgs()
7+
#include"pycore_ceval.h"// _PyEval_Vector()
78
#include"pycore_compile.h"// _PyAST_Compile()
89
#include"pycore_long.h"// _PyLong_CompactValue
10+
#include"pycore_modsupport.h"// _PyArg_NoKwnames()
911
#include"pycore_object.h"// _Py_AddToAllObjects()
1012
#include"pycore_pyerrors.h"// _PyErr_NoMemory()
1113
#include"pycore_pystate.h"// _PyThreadState_GET()
1214
#include"pycore_tuple.h"// _PyTuple_FromArray()
13-
#include"pycore_ceval.h"// _PyEval_Vector()
1415

1516
#include"clinic/bltinmodule.c.h"
1617

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp