diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2019-08-08 14:33:03 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2019-08-19 13:13:36 -0500 |
commit | c091779f63521e13d9f7af4ff113dde8cc5f6a7f (patch) | |
tree | ce1e29da778995b4467064d278a6a58a946e11ee /numpy/f2py/rules.py | |
parent | 684bee2ae868c1bd8cb4fd4066d447ca35bd848e (diff) | |
download | numpy-c091779f63521e13d9f7af4ff113dde8cc5f6a7f.tar.gz |
BUG: Further, followup f2py reference count fixes
Note that the extension module dict seems to be never dereferenced
(there is an additional reference to it kept around somewhere).
This reference seems to part of the C python module loading
(possibly intentionally), and I could not find how to remove it or
where it originates from.
Diffstat (limited to 'numpy/f2py/rules.py')
-rwxr-xr-x | numpy/f2py/rules.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 3097e51c1..f2f713bde 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -223,8 +223,14 @@ PyMODINIT_FUNC init#modulename#(void) { #endif \t\t\"This module '#modulename#' is auto-generated with f2py (version:#f2py_version#).\\nFunctions:\\n\"\n#docs#\".\"); \tPyDict_SetItemString(d, \"__doc__\", s); -\t#modulename#_error = PyErr_NewException (\"#modulename#.error\", NULL, NULL); \tPy_DECREF(s); +\t#modulename#_error = PyErr_NewException (\"#modulename#.error\", NULL, NULL); +\t/* +\t * Store the error object inside the dict, so that it could get deallocated. +\t * (in practice, this is a module, so it likely will not and cannot.) +\t */ +\tPyDict_SetItemString(d, \"_#modulename#_error\", #modulename#_error); +\tPy_DECREF(#modulename#_error); \tfor(i=0;f2py_routine_defs[i].name!=NULL;i++) { \t\ttmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]); \t\tPyDict_SetItemString(d, f2py_routine_defs[i].name, tmp); @@ -239,7 +245,6 @@ PyMODINIT_FUNC init#modulename#(void) { \tif (! PyErr_Occurred()) \t\ton_exit(f2py_report_on_exit,(void*)\"#modulename#\"); #endif - \treturn RETVAL; } #ifdef __cplusplus |