From 44cc728b25e83eef88cdc76b9fee5ef532bb005b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 7 Jan 2017 16:25:11 +0100 Subject: [PATCH] enforce a control to avoid crash if pcbnew.py is an incorrect version (bad install). --- pcbnew/swig/python_scripting.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pcbnew/swig/python_scripting.cpp b/pcbnew/swig/python_scripting.cpp index 876832baba..3c574266c9 100644 --- a/pcbnew/swig/python_scripting.cpp +++ b/pcbnew/swig/python_scripting.cpp @@ -213,8 +213,13 @@ static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wx PyLOCK lock; PyErr_Clear(); - PyObject* globals = PyDict_New(); - PyObject* builtins = PyImport_ImportModule( "pcbnew" ); + PyObject* builtins = PyImport_ImportModule( "pcbnew" ); + wxASSERT( builtins ); + + if( !builtins ) // Something is wrong in pcbnew.py module (incorrect version?) + return; + + PyObject* globals = PyDict_New(); PyDict_SetItemString( globals, "pcbnew", builtins ); Py_DECREF( builtins );