Skip to content

Commit 39506ee

Browse files
authored
gh-108240: Add pycore_capsule.h internal header file (#108596)
Move _PyCapsule_SetTraverse() definition to a new internal header file: pycore_capsule.h.
1 parent 4fb96a1 commit 39506ee

File tree

7 files changed

+24
-5
lines changed

7 files changed

+24
-5
lines changed

Include/internal/pycore_capsule.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef Py_INTERNAL_PYCAPSULE_H
2+
#define Py_INTERNAL_PYCAPSULE_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
// Export for '_socket' shared extension
12+
PyAPI_FUNC(int) _PyCapsule_SetTraverse(PyObject *op, traverseproc traverse_func, inquiry clear_func);
13+
14+
#ifdef __cplusplus
15+
}
16+
#endif
17+
#endif /* !Py_INTERNAL_PYCAPSULE_H */

Include/pycapsule.h

-5
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,10 @@ PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
4848

4949
PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
5050

51-
#ifdef Py_BUILD_CORE
52-
PyAPI_FUNC(int) _PyCapsule_SetTraverse(PyObject *op, traverseproc traverse_func, inquiry clear_func);
53-
#endif
54-
5551
PyAPI_FUNC(void *) PyCapsule_Import(
5652
const char *name, /* UTF-8 encoded string */
5753
int no_block);
5854

59-
6055
#ifdef __cplusplus
6156
}
6257
#endif

Makefile.pre.in

+1
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,7 @@ PYTHON_HEADERS= \
17431743
$(srcdir)/Include/internal/pycore_bytes_methods.h \
17441744
$(srcdir)/Include/internal/pycore_bytesobject.h \
17451745
$(srcdir)/Include/internal/pycore_call.h \
1746+
$(srcdir)/Include/internal/pycore_capsule.h \
17461747
$(srcdir)/Include/internal/pycore_ceval.h \
17471748
$(srcdir)/Include/internal/pycore_ceval_state.h \
17481749
$(srcdir)/Include/internal/pycore_code.h \

Modules/socketmodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Local naming conventions:
106106
#endif
107107

108108
#include "Python.h"
109+
#include "pycore_capsule.h" // _PyCapsule_SetTraverse()
109110
#include "pycore_dict.h" // _PyDict_Pop()
110111
#include "pycore_fileutils.h" // _Py_set_inheritable()
111112
#include "pycore_moduleobject.h" // _PyModule_GetState

Objects/capsule.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Wrap void * pointers to be passed between C modules */
22

33
#include "Python.h"
4+
#include "pycore_capsule.h" // export _PyCapsule_SetTraverse()
45
#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED()
56
#include "pycore_object.h" // _PyObject_GC_TRACK()
67

PCbuild/pythoncore.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
<ClInclude Include="..\Include\internal\pycore_bytes_methods.h" />
207207
<ClInclude Include="..\Include\internal\pycore_bytesobject.h" />
208208
<ClInclude Include="..\Include\internal\pycore_call.h" />
209+
<ClInclude Include="..\Include\internal\pycore_capsule.h" />
209210
<ClInclude Include="..\Include\internal\pycore_ceval.h" />
210211
<ClInclude Include="..\Include\internal\pycore_ceval_state.h" />
211212
<ClInclude Include="..\Include\internal\pycore_cfg.h" />

PCbuild/pythoncore.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@
528528
<ClInclude Include="..\Include\internal\pycore_call.h">
529529
<Filter>Include\internal</Filter>
530530
</ClInclude>
531+
<ClInclude Include="..\Include\internal\pycore_capsule.h">
532+
<Filter>Include\internal</Filter>
533+
</ClInclude>
531534
<ClInclude Include="..\Include\internal\pycore_ceval.h">
532535
<Filter>Include\internal</Filter>
533536
</ClInclude>

0 commit comments

Comments
 (0)