The Wayback Machine - https://web.archive.org/web/20200905014512/http://github.com/bpython/bpython/issues/841
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed() does not honor locals when a script is used #841

Open
ocurero opened this issue Aug 8, 2020 · 0 comments
Open

embed() does not honor locals when a script is used #841

ocurero opened this issue Aug 8, 2020 · 0 comments

Comments

@ocurero
Copy link

@ocurero ocurero commented Aug 8, 2020

Hi,

I'm using bpython to embed a python intepreter into my application. When a script is used, locals through embed() are lost:

from bpython import embed

def hello_world():
    return 'hello!'

embed({'hello': hello_world}, args=['bpython_issue_script.py'])

The script (bpython_issue_script.py) just contains a test: print('hello' in locals())

It should print True but prints False due to:

interpreter.locals = mod.__dict__

Commenting that line solves this issue for me, but I'm not sure if that is the correct fix.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.