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

Closures are not formed properly in interactive mode #277

Open
chaburkland opened this issue Jan 4, 2024 · 1 comment
Open

Closures are not formed properly in interactive mode #277

chaburkland opened this issue Jan 4, 2024 · 1 comment

Comments

@chaburkland
Copy link

I have found an issue where closures are not being formed properly when in interactive mode of an ipdb session. Namely, variables defined in the session are not visible to function closures.

Example:

$ python
Python 3.8.12 (default, Dec 18 2023, 10:05:54) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipdb; ipdb.set_trace()
--Return--
None
> <stdin>(1)<module>()

ipdb> x = None; [x for _ in [None]]  # Note how this works when not in interactive mode 
[None]
ipdb> interact
*interactive*
17:09:53  In [1] x = None; [x for _ in [None]]
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File <ipython-input-1-92de5d84d68a>:1
----> 1 x = None; [x for _ in [None]]

File <ipython-input-1-92de5d84d68a>:1, in <listcomp>(.0)
----> 1 x = None; [x for _ in [None]]

NameError: name 'x' is not defined

Another example:

17:11:13  In [1] x = None; f = lambda:x; f()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
File <ipython-input-1-95925a6f61cc>:1
----> 1 x = None; f = lambda:x; f()

File <ipython-input-1-95925a6f61cc>:1, in <lambda>()
----> 1 x = None; f = lambda:x; f()

NameError: name 'x' is not defined

These two examples work correctly inside interactive mode of pdb, or when in a normal ipython/python session.

Environment Info:

  • ipdb: 0.13.13
  • python: 3.8.12
@chaburkland
Copy link
Author

@brandtbucher This is the issue we saw together

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