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

ptpython.repl.embed fails to recognize local variables #279

Open
sodul opened this issue Dec 4, 2018 · 0 comments
Open

ptpython.repl.embed fails to recognize local variables #279

sodul opened this issue Dec 4, 2018 · 0 comments

Comments

@sodul
Copy link

sodul commented Dec 4, 2018

This works with the standard python REPL, when calling ptpython by itself but not when we use ptpython.replembed() in our scripts.

from ptpython.repl import embed
embed(globals(), locals())

Then in the REPL:

>>> y=True                                                                                                                                                     

>>> [y for x in 'abc']                                                                                                                                         
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <listcomp>
NameError: name 'y' is not defined

name 'y' is not defined

From the normal ptpython or the standard REPL:

$ ptpython
>>> y=True                                                                                                                                                     

>>> [y for x in 'abc']                                                                                                                                         
[True, True, True]

This is a similar issue as ipython/ipython#136

andersk added a commit to andersk/nixpkgs that referenced this issue Jan 31, 2021
This is a workaround for
prompt-toolkit/ptpython#279, which was making
it impossible to run the installer test interactively:

>>> start_all()
…
>>> test_script()
…
machine # [  382.137683] reboot: Power down
(7.06 seconds)
(8.23 seconds)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/lbn2xnibdcvpgkpbrkdh2vlf1ap6930v-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 888, in test_script
    exec(os.environ["testScript"])
  File "<string>", line 69, in <module>
  File "<string>", line 18, in create_machine_named
NameError: name 'default_flags' is not defined

name 'default_flags' is not defined

There’s no reason to expose the local variables of the run_tests
function, anyway.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
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

No branches or pull requests

1 participant