summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-03-16 13:15:01 (GMT)
committerGitHub <noreply@github.com>2020-03-16 13:15:01 (GMT)
commitf707d94af68a15afc27c1a9da5835f9456259fea (patch)
tree4c442bdd62c0f213bbf5445a034503280913e4b0 /Modules/_elementtree.c
parent4ab362cec6dc68c798b3e354f687cf39e207b9a9 (diff)
downloadcpython-f707d94af68a15afc27c1a9da5835f9456259fea.zip
cpython-f707d94af68a15afc27c1a9da5835f9456259fea.tar.gz
cpython-f707d94af68a15afc27c1a9da5835f9456259fea.tar.bz2
bpo-39968: Convert extension modules' macros of get_module_state() to inline functions (GH-19017)
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 2d6f26b..d2cad89 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -101,7 +101,13 @@ static struct PyModuleDef elementtreemodule;
/* Given a module object (assumed to be _elementtree), get its per-module
* state.
*/
-#define ET_STATE(mod) ((elementtreestate *) PyModule_GetState(mod))
+static inline elementtreestate*
+get_elementtree_state(PyObject *module)
+{
+ void *state = PyModule_GetState(module);
+ assert(state != NULL);
+ return (elementtreestate *)state;
+}
/* Find the module instance imported in the currently running sub-interpreter
* and get its state.
@@ -112,7 +118,7 @@ static struct PyModuleDef elementtreemodule;
static int
elementtree_clear(PyObject *m)
{
- elementtreestate *st = ET_STATE(m);
+ elementtreestate *st = get_elementtree_state(m);
Py_CLEAR(st->parseerror_obj);
Py_CLEAR(st->deepcopy_obj);
Py_CLEAR(st->elementpath_obj);
@@ -124,7 +130,7 @@ elementtree_clear(PyObject *m)
static int
elementtree_traverse(PyObject *m, visitproc visit, void *arg)
{
- elementtreestate *st = ET_STATE(m);
+ elementtreestate *st = get_elementtree_state(m);
Py_VISIT(st->parseerror_obj);
Py_VISIT(st->deepcopy_obj);
Py_VISIT(st->elementpath_obj);
@@ -4377,7 +4383,7 @@ PyInit__elementtree(void)
m = PyModule_Create(&elementtreemodule);
if (!m)
return NULL;
- st = ET_STATE(m);
+ st = get_elementtree_state(m);
if (!(temp = PyImport_ImportModule("copy")))
return NULL;