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

Re: svn commit: rev 5005 - trunk/subversion/tests/clients/cmdline/svntest

From: Greg Stein <gstein_at_lyra.org>
Date: 2003-02-22 04:46:07 CET

On Fri, Feb 21, 2003 at 10:54:31AM -0600, sussman@tigris.org wrote:
> Author: sussman
> Date: 2003-02-21 10:54:10 -0600 (Fri, 21 Feb 2003)
> New Revision: 5005
>
> Modified:
> trunk/subversion/tests/clients/cmdline/svntest/testcase.py
> Log:
>
> * testcase.py (TestCase::run): catch the SystemExit exception and
> really exit. This prevents us from finishing run_tests() and
> destroying the local_tmp/ area, which sometimes need for debugging.
>...
> +++ trunk/subversion/tests/clients/cmdline/svntest/testcase.py Fri Feb 21 10:54:15 2003
> @@ -84,6 +84,9 @@
> except KeyboardInterrupt:
> print "Interrupted"
> sys.exit(0)
> + except SystemExit:
> + print "Got a SystemExit exception, exiting."
> + sys.exit(0)
> except:
> print "caught unexpected exception"
> traceback.print_exc(file=sys.stdout)

Yikes. If some code does sys.exit(1), then you're transforming that into a
sys.exit(0). Not good.

The code should read:

  ...
  except SystemExit:
    # maybe print?
    raise
  except:
  ...

The bare 'raise' will re-raise the exception. This will allow you to exit
with the right value, and it will skip the cleanup stuff (since you bail out
of the run() method with an exception.

Basically, sys.exit() raises an exception. When the "outermost" level of
Python catches that, it turns it into a real exit() call.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Feb 22 04:41:58 2003

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.