Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -306,7 +306,7 @@ Py_{shortname}_init (Py_{shortname} * self, PyObject * args, PyObject * kwds) · 305 unmodified lines | |||
| 306 | out += """ | 306 | out += """ |
| 307 | // return -1 and set error string on failure | 307 | // return -1 and set error string on failure |
| 308 | if (self->o == NULL) {{ | 308 | if (self->o == NULL) {{ |
| 309 | PyErr_Format (PyExc_Exception, "failed creating {shortname}"); | 309 | PyErr_Format (PyExc_RuntimeError, "failed creating {shortname}"); |
| 310 | return -1; | 310 | return -1; |
| 311 | }} | 311 | }} |
| 312 | """.format(paramchars = paramchars, paramvals = paramvals, **self.__dict__) | 312 | """.format(paramchars = paramchars, paramvals = paramvals, **self.__dict__) |
| @@ -348,18 +348,20 @@ Py_{shortname}_del (Py_{shortname} * self, PyObject * unused) · 35 unmodified lines | |||
| 348 | for input_param in self.do_inputs: | 348 | for input_param in self.do_inputs: |
| 349 | if input_param['type'] == 'fmat_t *': | 349 | if input_param['type'] == 'fmat_t *': |
| 350 | out += """ | 350 | out += """ |
| 351 | free(self->{0[name]}.data);""".format(input_param) | 351 | free(self->{0[name]}.data);""".format(input_param) |
| 352 | for o in self.outputs: | 352 | for o in self.outputs: |
| 353 | name = o['name'] | 353 | name = o['name'] |
| 354 | del_out = delfromtype_fn[o['type']] | 354 | del_out = delfromtype_fn[o['type']] |
| 355 | out += """ | 355 | out += """ |
| 356 | {del_out}(self->{name});""".format(del_out = del_out, name = name) | 356 | if (self->{name}) {{ |
| 357 | {del_out}(self->{name}); | ||
| 358 | }}""".format(del_out = del_out, name = name) | ||
| 357 | del_fn = get_name(self.del_proto) | 359 | del_fn = get_name(self.del_proto) |
| 358 | out += """ | 360 | out += """ |
| 359 | if (self->o) {{ | 361 | if (self->o) {{ |
| 360 | {del_fn}(self->o); | 362 | {del_fn}(self->o); |
| 361 | }} | 363 | }} |
| 362 | Py_TYPE(self)->tp_free((PyObject *) self); | 364 | Py_TYPE(self)->tp_free((PyObject *) self); |
| 363 | }} | 365 | }} |
| 364 | """.format(del_fn = del_fn) | 366 | """.format(del_fn = del_fn) |
| 365 | return out | 367 | return out |