"print mymodule.cvar" crashes Python on Windows XP (Swig 1.3.36, Python 2.5, VC++ 2005) but works fine on Debian 4.0 (Swig 1.3.36, Python 2.4, gcc).
This looks like an old SWIG bug that was never fixed. See for example Bug#1058361 (Nov 2004) and http://www.nabble.com/simple-cvar-bug-td2636426.html#a2636794 (Jan 2006). These issues were resolved with a "Works for me on Linux" and "Does it work with the development version?", respectively.
The reason this is important is that that dir(mymodule.cvar) just returns an empty array, so the only way to find out what are the names of the global variables is with the print statement. (I'd actually prefer that the dir command worked, but I'll take what I get.)
Please let me know what other information you need to squash this bug.
With Python 3 and SWIG git master
print("Variables =", example.cvar)on thevariablesexample gives:(see https://ci.appveyor.com/project/swig/swig/builds/42898050/job/dkix6bohlmttv6r2#L740 at least until the log expires)
With Python 2.7 this gives:
I think that's calling
repr()instead ofstr()due to differences in howprintworks between Python 2 and Python 3. Anyway the crash is gone so closing.With Python 2.7 or 3.x and SWIG git master the
print("Variables = " + str(example.cvar))I've now added to thevariablesexample gives:(e.g. see https://ci.appveyor.com/project/swig/swig/builds/42898050/job/dkix6bohlmttv6r2#L740 at least until the log expires.)
The crash is gone and the list of variables returned so closing.