from IPython import embed
user_ns = dict(cookie='monster')
embed(user_ns=user_ns, banner1='Please type: cookie')
Bisecting shows the last good revision was 5397fc8, the following revisions don't have working embedding until 9a2ec9f, which has embedding but lost user_ns functionality.
I don't know how to write automated tests for embedding (can stdin be hijacked?).
I think I see the issue. user_ns when we create the shell is overridden by local_ns when we activate it. I'll think about the best way to resolve it.
This looks pretty serious, I really would hate for 0.12 to come out with broken embedding, seeing as it will be the ubuntu LTS ipython...
Right, there are four possibilities for each of user_ns and user_module when embedding:
I've got an idea how to resolve this. I'll put together a PR, hopefully this evening.
Funny coincidence: #136 and this (#1136) are both on scoping problems with the embedding code :)
Have a look at PR #1140.
Merged PR #1140, which resolves this.