Skip to content

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

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

Closed
ocurero opened this issue Aug 8, 2020 · 0 comments · Fixed by #895
Closed

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

ocurero opened this issue Aug 8, 2020 · 0 comments · Fixed by #895
Milestone

Comments

@ocurero
Copy link
Contributor

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!

sebastinas pushed a commit that referenced this issue Apr 20, 2021
@sebastinas sebastinas added this to the release-0.22 milestone Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants