From 43bffd3f7d11036c7aa966d431ae475d02c86ce4 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 29 May 2013 10:49:56 +0000 Subject: readPGF in the Python runtime now throws "No such file or directory" exception if the grammar is missing --- src/runtime/python/pypgf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/runtime/python') diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c index fa5103615..7fd6c5cdf 100644 --- a/src/runtime/python/pypgf.c +++ b/src/runtime/python/pypgf.c @@ -1640,7 +1640,12 @@ pgf_readPGF(PyObject *self, PyObject *args) // Read the PGF grammar. py_pgf->pgf = pgf_read(fpath, py_pgf->pool, err); if (!gu_ok(err)) { - PyErr_SetString(PGFError, "The grammar cannot be loaded"); + if (gu_exn_caught(err) == gu_type(GuErrno)) { + errno = *((GuErrno*) gu_exn_caught_data(err)); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, fpath); + } else { + PyErr_SetString(PGFError, "The grammar cannot be loaded"); + } Py_DECREF(py_pgf); gu_pool_free(tmp_pool); return NULL; -- cgit v1.2.3