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 -- Karlsruhe Institute of Technology (KIT) Communications Engineering Lab (CEL) Dipl.-Ing. Martin Braun Research Associate Kaiserstraße 12 Building 05.01 76131 Karlsruhe Phone: +49 721 608-43790 Fax: +49 721 608-46071 www.cel.kit.edu KIT -- University of the State of Baden-Württemberg and National Laboratory of the Helmholtz Association _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio