Index: Modules/atexitmodule.c =================================================================== --- Modules/atexitmodule.c (revision 66507) +++ Modules/atexitmodule.c (working copy) @@ -62,6 +62,8 @@ if (exc_type) PyErr_Restore(exc_type, exc_value, exc_tb); + + atexit_cleanup(); } void @@ -260,8 +262,5 @@ return NULL; _Py_PyAtExit(atexit_callfuncs); - /* Register a callback that will free - atexit_callbacks, otherwise valgrind will report memory leaks. */ - Py_AtExit(atexit_cleanup); return m; }