swig-py: Allow SubversionException to add attributes
A C API function can simultaneously return an error plus additional
non-error information. But in Python, returning an error (that is,
raising an exception) and returning (as a function return value) other
non-error information are somewhat mutually exclusive. With this
patch, we introduce a new set of typemaps to allow the bindings code
to attach any non-error information returned from an errorful C API
function as attributes to the raised exception so that callers can
access everything the C API returned.
[in subversion/bindings/swig/]
* include/svn_types.swg
(typemap(out) svn_error_t * SVN_ERR_WITH_ATTRS,
typemap(ret) svn_error_t * SVN_ERR_WITH_ATTRS):
New typemaps to all wrapper functions to use the attributes-on-
exception-objects feature. With these typemaps, the argout
typemaps can use the status code of the subversion error 'apr_err'
and the exception instance object 'exc_ob'.
* python/libsvn_swig_py/swigutil_py.h, python/libsvn_swig_py/swigutil_py.c
(svn_swig_py_build_svn_exception): New function, abstracted from...
(svn_swig_py_svn_exception): ...this, which now uses
svn_swig_py_build_svn_exception() to build the exception.
* svn_fs.i
(typemap(argout) (const char **conflict_p, svn_revnum_t *new_rev)):
Removed. This reverts the behavor that svn.fs.commit_txn()
always returns a 2-tuple of which the first item is always None.
(typemap(argout) (const char **conflict_p)):
New custom typemap to add the conflict path as an attibute to the
exception instance. This applies to svn_fs_merge(),
svn_fs_commit_txn() and svn_repos_fs_commit_txn().
(typemap(argout) (svn_revnum_t *new_rev)):
New custom typemap to add the created revision as an attibute to
the exception instance. This applies to svn_fs_commit_txn() and
svn_repos_fs_commit_txn().
(): Apply the 'SVN_ERR_WITH_ATTRS' typemap to svn_fs_merge()
and svn_fs_commit_txn().
* svn_repos.i
(): Apply the 'SVN_ERR_WITH_ATTRS' typemap to svn_repos_fs_merge().
Patch by: Yasuhito FUTATSUKI <futatuki at yf.bsdclub.org>
(Tweaked by me.)
git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1880967 13f79535-47bb-0310-9956-ffa450edef68
5 files changed