bugfix in the load method in the Python binding. The file was never closed.

This commit is contained in:
krasimir
2016-06-16 08:02:06 +00:00
parent cfe0542ea6
commit e95fa06133

View File

@@ -2257,13 +2257,13 @@ Concr_load(ConcrObject* self, PyObject *args)
// Read the PGF grammar. // Read the PGF grammar.
pgf_concrete_load(self->concr, in, err); pgf_concrete_load(self->concr, in, err);
if (!gu_ok(err)) { if (!gu_ok(err)) {
fclose(infile);
if (gu_exn_caught(err, GuErrno)) { if (gu_exn_caught(err, GuErrno)) {
errno = *((GuErrno*) gu_exn_caught_data(err)); errno = *((GuErrno*) gu_exn_caught_data(err));
PyErr_SetFromErrnoWithFilename(PyExc_IOError, fpath); PyErr_SetFromErrnoWithFilename(PyExc_IOError, fpath);
} else if (gu_exn_caught(err, PgfExn)) { } else if (gu_exn_caught(err, PgfExn)) {
GuString msg = (GuString) gu_exn_caught_data(err); GuString msg = (GuString) gu_exn_caught_data(err);
PyErr_SetString(PGFError, msg); PyErr_SetString(PGFError, msg);
return NULL;
} else { } else {
PyErr_SetString(PGFError, "The language cannot be loaded"); PyErr_SetString(PGFError, "The language cannot be loaded");
} }
@@ -2272,6 +2272,8 @@ Concr_load(ConcrObject* self, PyObject *args)
gu_pool_free(tmp_pool); gu_pool_free(tmp_pool);
fclose(infile);
Py_RETURN_NONE; Py_RETURN_NONE;
} }