summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2022-06-29 10:24:51 (GMT)
committerGitHub <noreply@github.com>2022-06-29 10:24:51 (GMT)
commit655b3aa4c8889a46e44b449cec16c85704a5e274 (patch)
tree1e96ef1b02a206475fb477786123fa7637c9ebfd
parent595baa4e061ec868fc36ada364ab8630e3f86942 (diff)
downloadcpython-655b3aa4c8889a46e44b449cec16c85704a5e274.zip
cpython-655b3aa4c8889a46e44b449cec16c85704a5e274.tar.gz
cpython-655b3aa4c8889a46e44b449cec16c85704a5e274.tar.bz2
gh-94401: Remove unneeded overlapped module state (#94403)
-rw-r--r--Modules/overlapped.c49
1 files changed, 6 insertions, 43 deletions
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index e40a524..19d25a5 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -105,18 +105,6 @@ typedef struct {
};
} OverlappedObject;
-typedef struct {
- PyTypeObject *overlapped_type;
-} OverlappedState;
-
-static inline OverlappedState*
-overlapped_get_state(PyObject *module)
-{
- void *state = PyModule_GetState(module);
- assert(state != NULL);
- return (OverlappedState *)state;
-}
-
static inline void
steal_buffer(Py_buffer * dst, Py_buffer * src)
@@ -1996,28 +1984,6 @@ static PyMethodDef overlapped_functions[] = {
{NULL}
};
-static int
-overlapped_traverse(PyObject *module, visitproc visit, void *arg)
-{
- OverlappedState *state = overlapped_get_state(module);
- Py_VISIT(state->overlapped_type);
- return 0;
-}
-
-static int
-overlapped_clear(PyObject *module)
-{
- OverlappedState *state = overlapped_get_state(module);
- Py_CLEAR(state->overlapped_type);
- return 0;
-}
-
-static void
-overlapped_free(void *module)
-{
- overlapped_clear((PyObject *)module);
-}
-
#define WINAPI_CONSTANT(fmt, con) \
do { \
PyObject *value = Py_BuildValue(fmt, con); \
@@ -2045,14 +2011,15 @@ overlapped_exec(PyObject *module)
return -1;
}
- OverlappedState *st = overlapped_get_state(module);
- st->overlapped_type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ PyTypeObject *overlapped_type = (PyTypeObject *)PyType_FromModuleAndSpec(
module, &overlapped_type_spec, NULL);
- if (st->overlapped_type == NULL) {
+ if (overlapped_type == NULL) {
return -1;
}
- if (PyModule_AddType(module, st->overlapped_type) < 0) {
+ int rc = PyModule_AddType(module, overlapped_type);
+ Py_DECREF(overlapped_type);
+ if (rc < 0) {
return -1;
}
@@ -2077,14 +2044,10 @@ static PyModuleDef_Slot overlapped_slots[] = {
};
static struct PyModuleDef overlapped_module = {
- PyModuleDef_HEAD_INIT,
+ .m_base = PyModuleDef_HEAD_INIT,
.m_name = "_overlapped",
- .m_size = sizeof(OverlappedState),
.m_methods = overlapped_functions,
.m_slots = overlapped_slots,
- .m_traverse = overlapped_traverse,
- .m_clear = overlapped_clear,
- .m_free = overlapped_free
};
PyMODINIT_FUNC