← Back to team overview

kicad-developers team mailing list archive

[PATCH] Python scripting crashed with multiple wxPython versions

 

Hi,
  I found that if you have multiple versions of wxPython (2.8 and 3.0)
installed and
enabled WX_PYTOHN_SCRIPTING macro, the wxPyCoreAPI_IMPORT call will
select the default one (in my case 2.8), and it will SEGV.

This because it does an import of wx._core_ and in my case is 2.8. (Ubuntu
14.04)

The patch calls wxversion.select() method to select 3.0 version before
wxCoreAPI_IMPORT call.

Cheers,
  Francesco
--- scripting/python_scripting.cpp	2014-04-02 13:38:59 +0000
+++ scripting/python_scripting.cpp	2014-09-29 05:53:51 +0000
@@ -140,6 +140,11 @@
 #ifdef KICAD_SCRIPTING_WXPYTHON
     PyEval_InitThreads();
 
+    // Make sure that we will use version 3.0. In systems where you have
+    // different versions of wx (eg. 2.8) this can lead to select wrong wx
+    // version.
+    PyRun_SimpleString("import wxversion; wxversion.select('3.0')");
+
     // Load the wxPython core API.  Imports the wx._core_ module and sets a
     // local pointer to a function table located there.  The pointer is used
     // internally by the rest of the API functions.


Follow ups