This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 7c3141632bc5d4d508aa12073383ac071add934f (commit) from 02150e7e23c559f9378d189e7435c2497284a4e9 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/7c3141632bc5d4d508aa12073383ac071add9...
commit 7c3141632bc5d4d508aa12073383ac071add934f Author: Cyril Hrubis metan@ucw.cz Date: Thu Mar 21 21:45:39 2013 +0100
pylib: common.i: Simplify error wrappers.
Make use of PyErr_SetFromErrno().
diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py index 707f0ca..d743c23 100755 --- a/demos/py_simple/progress_callback.py +++ b/demos/py_simple/progress_callback.py @@ -17,11 +17,18 @@ def main():
callback = core.c_core.GP_ProgressCallback(progress_callback)
- img = loaders.Load(sys.argv[1], callback) - print() - - img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback) - print() + try: + img = loaders.Load(sys.argv[1], callback) + print() + except RuntimeError as detail: + print("Failed to load image '{}': {}".format(sys.argv[1], detail)) + exit(1) + + try: + img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback) + print() + except RuntimeError: + print("Filter Aborted")
if __name__ == '__main__': main() diff --git a/pylib/gfxprim/common.i b/pylib/gfxprim/common.i index 2d17c0f..09dee68 100644 --- a/pylib/gfxprim/common.i +++ b/pylib/gfxprim/common.i @@ -23,12 +23,8 @@ %define ERROR_ON_NULL(funcname) %exception funcname { $action - if (result == NULL) { - char errbuf[128]; - char *errmsg = strerror_r(errno, errbuf, sizeof(errbuf)); - PyErr_Format(PyExc_RuntimeError, "Error in function %s: %s", "$name", errmsg); - return NULL; - } + if (result == NULL) + return PyErr_SetFromErrno(PyExc_RuntimeError); } %enddef
@@ -40,11 +36,7 @@ %define ERROR_ON_NONZERO(funcname) %exception funcname { $action - if (result != 0) { - char errbuf[128]; - char *errmsg = strerror_r(errno, errbuf, sizeof(errbuf)); - PyErr_Format(PyExc_RuntimeError, "Error in function %s: %s", "$name", errmsg); - return NULL; - } + if (result != 0) + return PyErr_SetFromErrno(PyExc_RuntimeError); } %enddef
-----------------------------------------------------------------------
Summary of changes: demos/py_simple/progress_callback.py | 17 ++++++++++++----- pylib/gfxprim/common.i | 16 ++++------------ 2 files changed, 16 insertions(+), 17 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.