Re: [PyCrust] C++ "throw" crashes PyCrust instead of triggering python traceback
Brought to you by:
pobrien
|
From: Sebastian H. <ha...@ms...> - 2003-05-15 19:20:06
|
> [Sorry, I didn't see this message right wawy because of a fault in my
> filters.]
>
> Patrick K. O'Brien wrote:
> > "Sebastian Haase" <ha...@ms...> writes:
> >
> >
> >>Hi all,
> >>I am writing C++ code that I make wrap (using SWIG) so that it's callabl
> >>from python.
> >>When there is a exception on the C++ level (C++ throw) this should be
get
> >>converted into an exception on the Python level, that is, I should see a
> >>python traceback. If I run python in the normal terminal window it
works
> >>like that. Also IDLE behaves well - giving the traceback.
> >>
> >>PyCrust on Linux used to seg-fault on this (2+ month ago?) but now it
works
> >>(since PyCrust 0.9 or so) -- THATS THE GOOD NEWS !!
> >>But the bad news is that on Windows it crahes -- I get
> >>"Runtime Error! Program: C:\python22\pythonw.exe -- abnormal program
> >>termination" -- and then 'OK' closes everything ...
> >>Here are the versions I use - I just got it yesterday from wxWindows CVS
> >>(2.4 branch)
> >>shell.about()
> >>Author: "Patrick K. O'Brien <po...@or...>"
> >>Py Version: 0.9.2
> >>Py Shell Revision: 1.1.2.5
> >>Py Interpreter Revision: 1.1.2.2
> >>Python Version: 2.2.2
> >>wxPython Version: 2.4.1.0p1
> >>Platform: win32
> >
> >
> > Thanks for the info. That's the latest version.
> >
> >
> >>Please help - or tell me how I can help ;-)
> >
> >
> > I wish I knew. I don't do any work with C++. Robin, got any ideas
> > about this? Anyone else? If not, you may want to post something to
> > comp.lang.python, since there are many more people there than on this
> > list.
>
> Please tell me a bit more about it. Does the exception work correctly
> on Windows if not run from PyCrust? What about if it is run from some
> other wxPython app? Can you extract and show us the code that is
> converting the c++ exception into the Python exception?
>
Hi Robin - Hi all,
I just ran some more test - and in fact the exceptions don't work right in
either PyCrust, IDLE or command-line...
When I did the tests before - that was on Linux ! and I got the 'abort' only
from PyCrust and not from IDLE or xterm.
(But as said above - now it works for me in Linux !)
I use SWIG * Version 1.3.17u-20021123-0854
on windows - the wrapper code has this code:
try {
result = (PriismFile *)new PriismFile((char const *)arg1,arg2,arg3);
}
catch(char const *&_e) {
{
PyErr_SetString(PyExc_RuntimeError, _e);
SWIG_fail;
}
}
catch(...) {
throw;
}
and PriismFile::PriismFile(...) contains this:
if(!pfStream) {
throw "Could not open file" ;
}
****
I JUST LEARNED ABOUT IT !!!!!
putting in printf- statements I found that it goes into the "catch(...)
" part !!!
So the problem seems to be that "text" doesn't get matched by "char const
*&"...
I'm using VC6++
Thanks for your interest - and making me think !!!!
Cheers,
Sebastian Haase
|