8000 [3.13] gh-134160: Use PyModuleDef.m_free in the example module xxlimi… · python/cpython@7620805 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7620805

Browse files
miss-islingtonencukouneonene
authored
8000
[3.13] gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174) (GH-135214)
gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174) (cherry picked from commit 1adca08) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
1 parent 58b9581 commit 7620805

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Modules/xxlimited.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ xx_clear(PyObject *module)
417417
return 0;
418418
}
419419

420+
static void
421+
xx_free(void *module)
422+
{
423+
// allow xx_modexec to omit calling xx_clear on error
424+
(void)xx_clear((PyObject *)module);
425+
}
426+
420427
static struct PyModuleDef xxmodule = {
421428
PyModuleDef_HEAD_INIT,
422429
.m_name = "xxlimited",
@@ -426,9 +433,7 @@ static struct PyModuleDef xxmodule = {
426433
.m_slots = xx_slots,
427434
.m_traverse = xx_traverse,
428435
.m_clear = xx_clear,
429-
/* m_free is not necessary here: xx_clear clears all references,
430-
* and the module state is deallocated along with the module.
431-
*/
436+
.m_free = xx_free,
432437
};
433438

434439

0 commit comments

Comments
 (0)
0