From: Guenter S. <Gue...@ph...> - 2009-09-01 03:53:01
|
See below. Robert Xiao wrote: > > > ---------- Forwarded message ---------- > From: *Robert Xiao* <nne...@gm... <mailto:nne...@gm...>> > Date: 2009/8/31 > Subject: Re: [Visualpython-users] Problems with exception handling in > vpython on Linux > To: Guenter Schneider <Gue...@ph... > <mailto:Gue...@ph...>> > > > 2009/8/31 Guenter Schneider <Gue...@ph... > <mailto: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? boost 1.35 (libboost1.35-dev) > > > 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. I was guessing and did not try everything on Windows. > > >>> 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? Yes. > > 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. > All end in seg. faults on my system. In [1]: from visual import * In [2]: faces(normal=[]) Segmentation fault I appreciate your help. Guenter > > > 2009/8/31 Bruce Sherwood <Bru...@nc... > <mailto: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 > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > > ------------------------------------------------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users -- ----------------------------------------------------- Guenter Schneider Email: Gue...@ph... Phone: 541 737 1706 Fax: 541 737 1683 Oregon State University Department of Physics 301 Weniger Hall Corvallis, OR 97331-6507, USA ----------------------------------------------------- |