|
Swig + Python + C++ + overloading + None = SEGV.: msg#00169programming.swig
Hello, I just noticed that if you pass None from Python to an overloaded C++ function as the argument overloading resolution is based on, you will probably crash the interpreter. The reason is that it uses SWIG_ConvertPtr for typechecking and that will always succeed on None, converting it to a null pointer, which usually gets dereferenced later. Example: ----8<---- %module oltest %{ #include <iostream> using namespace std; %} %inline %{ struct foo { int x; }; struct bar { float y; }; static void foobar( foo x) { cout << "foo " << x.x << endl; } static void foobar( bar x) { cout << "bar " << x.y << endl; } %} ---->8---- Compile and import to Python, then try oltest.foobar( None). -- Timo Korvola <URL:http://www.iki.fi/tkorvola> _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | ANN: F2PY - Fortran to Python Interface Generator: 00169, Pearu Peterson |
|---|---|
| Next by Date: | swig on vxworks: 00169, Ranjan, Ashish (GE Healthcare) |
| Previous by Thread: | ANN: F2PY - Fortran to Python Interface Generatori: 00169, Pearu Peterson |
| Next by Thread: | Re: Swig + Python + C++ + overloading + None = SEGV.: 00169, Marcelo Matus |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |