title: Python initialization segfault
body: <p>I'm building app with boost.python. I have some singleton class named <code>ScriptsManager</code>, it has function <code>initPython</code> which does:</p>
  
  <pre><code>mMainModule = bp::import("__main__");
  mMainNamespace = bp::import("__dict__");
  
  bp::object ignored = bp::exec("hello = file('hello.txt', 'w')\n"
                    "hello.write('Hello world!')\n"
                    "hello.close()", mMainNamespace);
  </code></pre>
  
  <p>both <code>mMainModule, mMainNamespace</code> are <code>boost::python::object</code>.</p>
  
  <p>So, when I start application, I get:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x0000000000000000 in ?? ()
  (gdb) bt
  #0  0x0000000000000000 in ?? ()
  #1  0x00007ffff5d5efd9 in PyEval_GetGlobals () from /usr/lib/libpython2.7.so.1.0
  #2  0x00007ffff5d79113 in PyImport_Import () from /usr/lib/libpython2.7.so.1.0
  #3  0x00007ffff5d7935c in PyImport_ImportModule () from /usr/lib/libpython2.7.so.1.0
  #4  0x00007ffff5a6d8bd in boost::python::import(boost::python::str) () from /usr/lib/libboost_python.so.1.46.0
  #5  0x0000000000510b1b in ScriptsManager::initPython (this=0x7b6850) at /home/ockonal/Workspace/Themisto/src/Core/ScriptsManager.cpp:24
  #6  0x0000000000547650 in Application::main (args=...) at /home/ockonal/Workspace/Themisto/src/main.cpp:60
  #7  0x00007ffff4ebbf86 in main () from /usr/lib/libclan22App-2.2.so.1
  #8  0x00007ffff24c4dcd in __libc_start_main () from /lib/libc.so.6
  #9  0x00000000004c9769 in _start ()
  </code></pre>
  
  <p>What could be wrong here?</p>
  
  <hr>
  
  <p><strong>UPD1</strong></p>
  
  <p>When I call <code>Py_Initialize()</code> before <code>bp::import</code> I get:</p>
  
  <blockquote>
    <p>terminate called after throwing an
    instance of
    'boost::python::error_already_set'</p>
  </blockquote>
  
  <hr>
  
  <p><strong>UPD2</strong></p>
  
  <p>Seems that problem was in code:</p>
  
  <pre><code>mMainNamespace = bp::import("__dict__");
  </code></pre>
  
  <p>The result code is:</p>
  
  <pre><code>Py_Initialize();
  mMainModule = bp::import("__main__");
  mMainNamespace = mMainModule.attr("__dict__");
  </code></pre>
  
  <p>I'm not sure it's right.</p>
  
  <hr>
  
  <p><strong>UPD3</strong></p>
  
  <p>Yep, <strong>2</strong>-nd update works. So strange, <code>mMainNamespace = bp::import("__dict__")</code> is written in official boost docs.</p>