https://github.com/python/cpython/commit/dd4a819a82dd488ffa8352e4367cf3a749f6bf3e
commit: dd4a819a82dd488ffa8352e4367cf3a749f6bf3e
branch: 3.14
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: encukou <encu...@gmail.com>
date: 2025-06-06T17:08:45+02:00
summary:

[3.14] gh-134160: Use PyModuleDef.m_free in the example module xxlimited 
(GH-135174) (GH-135213)

gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174)
(cherry picked from commit 1adca08d658ee2d520f3193960eaf3ae2ead1cef)

Co-authored-by: Petr Viktorin <encu...@gmail.com>
Co-authored-by: neonene <53406459+neon...@users.noreply.github.com>

files:
M Modules/xxlimited.c

diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
index 26ac35734fb060..0480fb0849876b 100644
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -424,6 +424,13 @@ xx_clear(PyObject *module)
     return 0;
 }
 
+static void
+xx_free(void *module)
+{
+    // allow xx_modexec to omit calling xx_clear on error
+    (void)xx_clear((PyObject *)module);
+}
+
 static struct PyModuleDef xxmodule = {
     PyModuleDef_HEAD_INIT,
     .m_name = "xxlimited",
@@ -433,9 +440,7 @@ static struct PyModuleDef xxmodule = {
     .m_slots = xx_slots,
     .m_traverse = xx_traverse,
     .m_clear = xx_clear,
-    /* m_free is not necessary here: xx_clear clears all references,
-     * and the module state is deallocated along with the module.
-     */
+    .m_free = xx_free,
 };
 
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to