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

Re: Getting better error messages out of the Python bindings

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2004-12-08 19:23:31 CET

François Beausoleil <fbeausoleil@ftml.net> writes:

> from svn import core, fs, repos
>
> def repro(pool):
> repos.svn_repos_open('no-repos-named-that-way', pool)
>
> def main():
> print core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO
> core.run_app(repro)
>
> if __name__ == '__main__':
> main()
>
>
> On my machine, the output looks like this:
> 1 1 1
> Traceback (most recent call last):
> File "C:\java\rsvn\recipe.py", line 11, in ?
> main()
> File "C:\java\rsvn\recipe.py", line 8, in main
> core.run_app(repro)
> File "C:\Python23\lib\svn\core.py", line 33, in run_app
> return apply(func, (pool,) + args, kw)
> File "C:\java\rsvn\recipe.py", line 4, in repro
> repos.svn_repos_open('no-repos-named-that-way', pool)
> SystemError: null argument to internal routine

Somethis is wrong with your bindings, then, because I get:

   $ ./test.py
   1 2 0
   Traceback (most recent call last):
     File "./test.py", line 12, in ?
       main()
     File "./test.py", line 9, in main
       core.run_app(repro)
     File "/usr/lib/python2.3/site-packages/svn/core.py", line 37, in run_app
       return apply(func, (pool,) + args, kw)
     File "./test.py", line 5, in repro
       repos.svn_repos_open('no-repos-named-that-way', pool)
   libsvn._core.SubversionException: ("Can't open file 'no-repos-named-that-way/format': No such file or directory", 2)

I designed those SubversionException errors such that you can grab
their apr_err member to get the numeric errorcode, too. So this
slightly tweaked version of you script:

   #!/usr/bin/python
   from svn import core, fs, repos
   
   def repro(pool):
      try:
         repos.svn_repos_open('no-repos-named-that-way', pool)
      except core.SubversionException, e:
         print "ERROR (code=%d): %s" % (e.apr_err, str(e))
   
   def main():
      print core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO
      core.run_app(repro)
   
   if __name__ == '__main__':
      main()

produces this output:

   $ ./test.py
   1 2 0
   ERROR (code=2): ("Can't open file 'no-repos-named-that-way/format': No such file or directory", 2)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Dec 8 19:27:18 2004

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

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