On Tue, Jun 5, 2012 at 2:58 PM, Martin Braun <martin.br...@kit.edu> wrote: > On Sun, Jun 03, 2012 at 10:22:14AM -0400, Tom Rondeau wrote: >> On the other hand, I thought all standard exceptions were passed >> properly through SWIG to Python already. I was under the impression >> that if you're header file declares that it throws, then you can catch >> it in Python. If that's not the case, then we should try to figure out >> an easy way to handle that. > > Hi Tom and rest, > > so, I didn't do my research properly (partly): Exceptions *are* caught by > SWIG, *but* they always end up as RuntimeErrors, regardless of what the > exception type was in C++. > > So, for future reference: > If you throw a std::invalid_argument in a block constructor, it ends > up as a RuntimeError in Python. If you hand-edit the SWIG file and add > an exception specifier, it ends up as a ValueError, which I think is the > better behaviour, and it would be great if SWIG did this automatically. > > But frankly, I don't think this is that big a deal, I'll just catch > RuntimeErrors instead of ValueErrors. Or edit .i-files. > > There's just no "clean" way to do this, because you'd either have to > specify the exceptions in the header (which is deprecated C++), write a > .i (redundant) or lose the exception type. > > MB
Yeah, I remember looking at this a while ago (since there is still an error where FreeBSD treats one particular exception incorrectly). There are a few exceptions that are handled by SWIG, but mostly the C++ ones just get smashed into one or maybe two different exceptions in Python. I'm of the opinion that I agree that it's not a big deal. An exception might now be technically incorrect, but I think we can translate as needed. Tom _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio