diff options
-rwxr-xr-x[-rw-r--r--] | numpy/f2py/rules.py | 9 | ||||
-rw-r--r-- | numpy/f2py/src/fortranobject.c | 7 |
2 files changed, 11 insertions, 5 deletions
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 6769f1b1f..1b41498ea 100644..100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -202,7 +202,7 @@ PyMODINIT_FUNC PyInit_#modulename#(void) { PyMODINIT_FUNC init#modulename#(void) { #endif \tint i; -\tPyObject *m,*d, *s; +\tPyObject *m,*d, *s, *tmp; #if PY_VERSION_HEX >= 0x03000000 \tm = #modulename#_module = PyModule_Create(&moduledef); #else @@ -224,8 +224,11 @@ PyMODINIT_FUNC init#modulename#(void) { \tPyDict_SetItemString(d, \"__doc__\", s); \t#modulename#_error = PyErr_NewException (\"#modulename#.error\", NULL, NULL); \tPy_DECREF(s); -\tfor(i=0;f2py_routine_defs[i].name!=NULL;i++) -\t\tPyDict_SetItemString(d, f2py_routine_defs[i].name,PyFortranObject_NewAsAttr(&f2py_routine_defs[i])); +\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); +\t\tPy_DECREF(tmp); +\t} #initf2pywraphooks# #initf90modhooks# #initcommonhooks# diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index 4a981bf55..b55385b50 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -80,7 +80,10 @@ PyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module PyFortranObject *fp = NULL; fp = PyObject_New(PyFortranObject, &PyFortran_Type); if (fp == NULL) return NULL; - if ((fp->dict = PyDict_New())==NULL) return NULL; + if ((fp->dict = PyDict_New())==NULL) { + PyObject_Del(fp); + return NULL; + } fp->len = 1; fp->defs = defs; return (PyObject *)fp; @@ -91,7 +94,7 @@ PyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module static void fortran_dealloc(PyFortranObject *fp) { Py_XDECREF(fp->dict); - PyMem_Del(fp); + PyObject_Del(fp); } |