title: How run a Python script from another script and get resulting global dict?
body: <p>Let's say you have a string containing a path to a Python script and you want to load and execute that script in transparent way (so that there are not fundamental differences for inner script compared to being run directly via “python path”). And then get the resulting global dict. I thought that runpy.run_path() does this but there are two issues. If the path contains some unicode character then it doesn't work (see <a href="http://bugs.python.org/issue17588" rel="nofollow">http://bugs.python.org/issue17588</a>). And most importantly, given global dict is just a copy of original one, since this original one is purged when temporary module object is garbage collected. So a function object have corrupted __globals__ dict (see <a href="http://bugs.python.org/issue18331" rel="nofollow">http://bugs.python.org/issue18331</a>).</p>
  
  <p>Have you any ideas how to run the inner script?</p>
  
  <p><em>Update:</em> See my current approach – <a href="http://bpaste.net/show/RzAbQxLNXiJsXYm2fplz/" rel="nofollow">http://bpaste.net/show/RzAbQxLNXiJsXYm2fplz/</a> . Any suggestions? Improvements? For example about the details of what can be different from point of view of a script being run. I know about issue with realoading __main__.</p>