[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Python bindings problem (1.3.0)

From: David James <djames_at_collab.net>
Date: 2006-01-29 08:00:41 CET

On 1/15/06, Paulo da Silva <psdasilva@esoterica.pt> wrote:
> 1.
> I am trying the python subversion API.
> So, I tried the example from the book where
> svn_client_status is used. It worked fine.
> Then I made a simple modification changing
> svn_client_status to svn_client_status2.
> As consequence, I also added the new parameter
> ignore_externals as 0 just before ctx.
> I got the following error message:
> TypeError: argument number 3: a 'svn_wc_status_func2_t' is expected,
> 'function(<function _status_callback at 0xb7b30e2c>)' is received
>
> What is wrong? This seems to make no sense in python!

This is a bug in the Python bindings. For now, I would recommend to
use svn_client_status until svn_client_status2 is fixed.

> 2.
> Anyway, how can I know what parameters to use when calling
> python binding functions?
> The c headers helped me but they
> didn't match exactly the python ones.
> I don't know SWIG. Is this needed?

Unfortunately the documentation for the SWIG bindings is limited at
the moment. The Python functions differ from the C functions because
output parameters are returned as return values instead of as
pointers. Further, all apr pool arguments are optional. Here's an
example:

C header:
/* Add "a" and "b", store result in *result. Returns SVN_NO_ERROR. */
svn_error_t add(int a, int b, int *result, apr_pool_t *pool)

To use this function, you can type:
  result = add(a,b)

If you like to manage your memory manually, you can also pass in a memory pool:
  result = add(a,b,pool)

It's generally easier to let the Python bindings manage your memory
for you. This is a new feature in Subversion 1.3.

Cheers,

David

--
David James -- http://www.cs.toronto.edu/~james
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Sun Jan 29 08:01:41 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.