FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythoncapi-compat/tests/extension.c at main · python/pythoncapi-compat · GitHub
python
pythoncapi-compat
Repository navigation
Code
Issues
1
(1)
Pull requests
1
(1)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythoncapi-compat
/
tests
/
extension.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
77 lines (59 loc) · 1.91 KB
Breadcrumbs
pythoncapi-compat
/
tests
/
extension.c
Copy path
File metadata and controls
77 lines (59 loc) · 1.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// C extension made of two C files (extension.c and static_inline.c) to detect
// when a pythoncapi_compat.h function is implemented without "static inline".
#ifndef
MODULE_NAME
# error
"MODULE_NAME macro is not set"
#endif
#include
"pythoncapi_compat.h"
#define
_STR
(
NAME
) #NAME
#define
STR
(
NAME
) _STR(NAME)
#define
_CONCAT
(
a
,
b
) a ## b
#define
CONCAT
(
a
,
b
) _CONCAT(a, b)
// No method and no module exec method needed, most basic C extension
// Use PySlot API on Python 3.15 and newer and on limited C API 3.15 and newer
#if
(
PY_VERSION_HEX
>=
_Py_PACK_VERSION
(
3
,
15
) \
&&
(!defined(
Py_LIMITED_API
)
||
Py_LIMITED_API
+
0
>=
_Py_PACK_VERSION
(
3
,
15
)))
PyABIInfo_VAR
(
abi_info
);
static
PySlot
module_slots
[]
=
{
PySlot_PTR_STATIC
(
Py_mod_abi
,
&
abi_info
),
PySlot_PTR_STATIC
(
Py_mod_name
, (
void
*
)
STR
(
MODULE_NAME
)),
PySlot_PTR_STATIC
(
Py_mod_state_size
,
0
),
PySlot_PTR_STATIC
(
Py_mod_gil
,
Py_MOD_GIL_NOT_USED
),
{
0
,
0
, {
0
}, {
0
}}
};
#define
EXPORT_FUNC
CONCAT(PyModExport_, MODULE_NAME)
PyMODEXPORT_FUNC
EXPORT_FUNC
(
void
)
{
return
module_slots
;
}
#ifdef
MS_WINDOWS
# define
INIT_FUNC
CONCAT(PyInit_, MODULE_NAME)
// Workaround for https://github.com/pypa/distutils/issues/387
// https://docs.python.org/3.16/howto/abi3t-migration.html#module-export-hook
PyMODINIT_FUNC
INIT_FUNC
(
void
)
{
PyErr_SetString
(
PyExc_SystemError
,
"PyInit_* called for module with PyModExport_*"
);
return
NULL
;
}
#endif
#else
static
struct
PyModuleDef
module_def
=
{
PyModuleDef_HEAD_INIT
,
STR
(
MODULE_NAME
),
// m_name
_Py_NULL
,
// m_doc
0
,
// m_size
_Py_NULL
,
// m_methods
_Py_NULL
,
// m_slots
_Py_NULL
,
// m_traverse
_Py_NULL
,
// m_clear
_Py_NULL
,
// m_free
};
#define
INIT_FUNC
CONCAT(PyInit_, MODULE_NAME)
PyMODINIT_FUNC
INIT_FUNC
(
void
)
{
return
PyModule_Create
(
&
module_def
);
}
#endif
Back
|
FazBrowse Home
|
New Git URL