comparison Python/Python-ast.c @ 36794:df843b07f5fe legacy-trunk

Fix memory leak on attributes.
author Martin v. Löwis <martin@v.loewis.de>
date Thu, 02 Mar 2006 00:31:27 +0000
parents 57322cb2ca11
children f731859e9b3b dfc33ec7f73a
comparison
equal deleted inserted replaced
36793:1e8cb47beaaa 36794:df843b07f5fe
2322 if (!result) goto failed; 2322 if (!result) goto failed;
2323 break; 2323 break;
2324 } 2324 }
2325 value = ast2obj_int(o->lineno); 2325 value = ast2obj_int(o->lineno);
2326 if (!value) goto failed; 2326 if (!value) goto failed;
2327 PyObject_SetAttrString(result, "lineno", value); 2327 if (PyObject_SetAttrString(result, "lineno", value) < 0)
2328 goto failed;
2329 Py_DECREF(value);
2328 value = ast2obj_int(o->col_offset); 2330 value = ast2obj_int(o->col_offset);
2329 if (!value) goto failed; 2331 if (!value) goto failed;
2330 PyObject_SetAttrString(result, "col_offset", value); 2332 if (PyObject_SetAttrString(result, "col_offset", value) < 0)
2333 goto failed;
2334 Py_DECREF(value);
2331 return result; 2335 return result;
2332 failed: 2336 failed:
2333 Py_XDECREF(value); 2337 Py_XDECREF(value);
2334 Py_XDECREF(result); 2338 Py_XDECREF(result);
2335 return NULL; 2339 return NULL;
2641 Py_DECREF(value); 2645 Py_DECREF(value);
2642 break; 2646 break;
2643 } 2647 }
2644 value = ast2obj_int(o->lineno); 2648 value = ast2obj_int(o->lineno);
2645 if (!value) goto failed; 2649 if (!value) goto failed;
2646 PyObject_SetAttrString(result, "lineno", value); 2650 if (PyObject_SetAttrString(result, "lineno", value) < 0)
2651 goto failed;
2652 Py_DECREF(value);
2647 value = ast2obj_int(o->col_offset); 2653 value = ast2obj_int(o->col_offset);
2648 if (!value) goto failed; 2654 if (!value) goto failed;
2649 PyObject_SetAttrString(result, "col_offset", value); 2655 if (PyObject_SetAttrString(result, "col_offset", value) < 0)
2656 goto failed;
2657 Py_DECREF(value);
2650 return result; 2658 return result;
2651 failed: 2659 failed:
2652 Py_XDECREF(value); 2660 Py_XDECREF(value);
2653 Py_XDECREF(result); 2661 Py_XDECREF(result);
2654 return NULL; 2662 return NULL;
3021 if (!m) return; 3029 if (!m) return;
3022 d = PyModule_GetDict(m); 3030 d = PyModule_GetDict(m);
3023 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; 3031 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
3024 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) 3032 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
3025 return; 3033 return;
3026 if (PyModule_AddStringConstant(m, "__version__", "42649") < 0) 3034 if (PyModule_AddStringConstant(m, "__version__", "42753") < 0)
3027 return; 3035 return;
3028 if(PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; 3036 if(PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
3029 if(PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) 3037 if(PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
3030 return; 3038 return;
3031 if(PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) 3039 if(PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type)