Rev 1056: Deal with Python exceptions that happened in callbacks. in file:///data/jelmer/bzr-svn/cext/
Jelmer Vernooij
jelmer at samba.org
Tue Jun 3 00:12:22 BST 2008
At file:///data/jelmer/bzr-svn/cext/
------------------------------------------------------------
revno: 1056
revision-id: jelmer at samba.org-20080602231220-2xzilofx2jv4ficj
parent: jelmer at samba.org-20080602221108-60v4fkg8ie9q1hog
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Tue 2008-06-03 01:12:20 +0200
message:
Deal with Python exceptions that happened in callbacks.
modified:
util.c util.c-20080531154025-s8ef6ej9tytsnkkw-1
util.h util.h-20080531154025-s8ef6ej9tytsnkkw-2
=== modified file 'util.c'
--- a/util.c 2008-06-02 20:15:47 +0000
+++ b/util.c 2008-06-02 23:12:20 +0000
@@ -21,6 +21,14 @@
#include <apr_general.h>
#include <svn_error.h>
#include <svn_io.h>
+#include <apr_errno.h>
+#include <svn_error_codes.h>
+
+#include "util.h"
+
+#define BZR_SVN_APR_ERROR_OFFSET (APR_OS_START_USERERR + \
+ (50 * SVN_ERR_CATEGORY_SIZE))
+
apr_pool_t *Pool(apr_pool_t *parent)
{
@@ -39,8 +47,7 @@
PyObject *PyErr_NewSubversionException(svn_error_t *error)
{
-
- return NULL; /* FIXME */
+ return Py_BuildValue("(si)", error->message, error->apr_err);
}
void PyErr_SetSubversionException(svn_error_t *error)
@@ -55,11 +62,14 @@
bool check_error(svn_error_t *error)
{
- if (error != NULL) {
- PyErr_SetSubversionException(error);
- return false;
- }
- return true;
+ if (error == NULL)
+ return true;
+
+ if (error->apr_err == BZR_SVN_APR_ERROR_OFFSET)
+ return false; /* Just let Python deal with it */
+
+ PyErr_SetSubversionException(error);
+ return false;
}
apr_array_header_t *string_list_to_apr_array(apr_pool_t *pool, PyObject *l)
@@ -135,13 +145,14 @@
}
ret = PyObject_CallFunction((PyObject *)baton, "OiO", py_changed_paths,
revision, revprops);
- /* FIXME: Handle ret != NULL */
+ if (ret == NULL)
+ return py_svn_error();
return NULL;
}
-svn_error_t *py_svn_error(void)
+svn_error_t *py_svn_error()
{
- return NULL; /* FIXME */
+ return svn_error_create(BZR_SVN_APR_ERROR_OFFSET, NULL, "Error occured in python bindings");
}
PyObject *wrap_lock(svn_lock_t *lock)
=== modified file 'util.h'
--- a/util.h 2008-06-02 18:58:48 +0000
+++ b/util.h 2008-06-02 23:12:20 +0000
@@ -43,4 +43,5 @@
PyObject *PyErr_NewSubversionException(svn_error_t *error);
svn_error_t *py_cancel_func(void *cancel_baton);
+
#endif /* _BZR_SVN_UTIL_H_ */
More information about the bazaar-commits
mailing list