Fix builtins import in Python3
This commit is contained in:
parent
f316b98f45
commit
0812f71bd3
|
@ -63,8 +63,12 @@ class PcbnewPyShell(editor.EditorNotebookFrame):
|
|||
intro = 'Py %s' % version.VERSION
|
||||
import imp
|
||||
module = imp.new_module('__main__')
|
||||
import __builtin__
|
||||
module.__dict__['__builtins__'] = __builtin__
|
||||
if sys.version_info >= (3,):
|
||||
import builtins
|
||||
module.__dict__['__builtins__'] = builtins
|
||||
else:
|
||||
import __builtin__
|
||||
module.__dict__['__builtins__'] = __builtin__
|
||||
namespace = module.__dict__.copy()
|
||||
|
||||
self.config_dir = pcbnew.GetKicadConfigPath()
|
||||
|
|
|
@ -338,7 +338,13 @@ wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameI
|
|||
// executed. Put a reference to the builtins module in it.
|
||||
|
||||
PyObject* globals = PyDict_New();
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject* builtins = PyImport_ImportModule( "builtins" );
|
||||
#else
|
||||
PyObject* builtins = PyImport_ImportModule( "__builtin__" );
|
||||
#endif
|
||||
|
||||
wxASSERT( builtins );
|
||||
|
||||
PyDict_SetItemString( globals, "__builtins__", builtins );
|
||||
Py_DECREF( builtins );
|
||||
|
|
Loading…
Reference in New Issue