inducer / inducer/pudb

Function definitions don't use the proper namespace in the IPython shell

Open
#280 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.2k
Forks
245
Avg merge
13m
Merged PRs (30d)
5

Description

For instance, if you run

```
a = 1
```

and

```
def test():
print(a)

test()
```

in the IPython shell, it gives `NameError: name 'a' is not defined`.

The use of SetPropagatingDict would fix this. It looks like the IPython shell is doing some weird stuff, so I'm not exactly clear on how to fix this.

Also we should update the docs for SetPropagatingDict to make it clear that basically every shell should use it, unless they really know what they are doing. This is because globals/locals being separate dictionaries creates odd behavior with exec (basically, it acts like a class body), which is generally much different from what you would expect from a shell.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the IPython shell example with a global variable referenced inside a function, then inspect the shell execution path and the mentioned SetPropagatingDict behavior. Done means the example resolves the variable correctly and the SetPropagatingDict documentation explains why shells should generally use it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.