|
From: Robert X. <nne...@gm...> - 2009-08-31 23:09:27
|
---------- Forwarded message ----------
From: Robert Xiao <nne...@gm...>
Date: 2009/8/31
Subject: Re: [Visualpython-users] Problems with exception handling in
vpython on Linux
To: Guenter Schneider <Gue...@ph...>
2009/8/31 Guenter Schneider <Gue...@ph...>
> I ran into a number of problems with vpython on Linux which appear to be
> all related. The problems do not happen in Windows. My system is ubuntu
> 9.04, vpython 5.12 compiled from source (5.11 gives identical results).
>
What version of the Boost libraries are you using?
> Thee common feature I see on Linux is, whenever vpython raises an
> exception, python seg. faults.
>
> Example 1:
>
> In [1]: from visual import *
>
> In [2]: a = vector(1,2,3)
>
> In [3]: for i in a:
> ...: print i
> ...:
> ...:
> 1.0
> 2.0
> 3.0
> Segmentation fault
> ~ $
>
> but the following works:
>
> Example 2:
>
> In [1]: from visual import *
>
> In [2]: a = vector(1,2,3)
>
> In [3]: for i in a:
> ...: print i
> ...: if i>2:
> ...: break
> ...:
> ...:
> 1.0
> 2.0
> 3.0
>
> This seems to point to the raising a StopIteration exception as the
> problem point.
>
> Example 3:
> In [1]: from visual import *
>
> In [2]: a = [1,2,3]
>
> In [3]: mag2(a)
> Out[3]: 14.0
>
> In [4]: a = [1,2,'x']
>
> In [5]: mag2(a)
> Segmentation fault
> ~ $
>
> It should have raised a TypeError as in this case
>
It's actually Boost.Python.ArgumentError, since [1,2,'x'] can't be coerced
to a vector, so it is passed in as a list.
>>> visual.mag2([1,2,'x'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
visual.cvisual.mag2(list)
did not match C++ signature:
mag2(class cvisual::vector)
mag2(class boost::python::numeric::array)
> Finally this fails as well:
>
> Example 5:
> In [1]: from visual import *
>
> In [2]: quit()
> Do you really want to exit ([y]/n)?
> Segmentation fault
> ~ $
>
quit() is a Python built-in, and it isn't overridden by Visual. Does quit()
work if you don't import visual?
Can you try these tests:
vector(1,2,3)[4] # throws std::out_of_range
vector('x')
faces(pos=[1])
faces(normal=[])
These all directly throw exceptions.
2009/8/31 Bruce Sherwood <Bru...@nc...>
> Moreover, your Example 1 is exceptionally strange, as it should not give an
> error of any kind (nor does it give an error for me). Is it possible that
> there's a typo in your reporting of Example 1?
>
StopIteration is raised by an iterator when it has no more objects to
iterate over. It is not an error, but it can be raised by an iterator.
Robert
|