ipython / ipython/ipython

Better handling of `__main__.__file__` for debugger.Pdb

Open
#3,130 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16.8k
Forks
4.5k
Avg merge
1d 2h
Merged PRs (30d)
6

Description

Related to #2460, the following code causes python to lose access to the `__main__` module's `__file__` variable, because Pdb internally uses ipapi to launch an interactive shell. It would be nice if in this case, the `__file__` variable was not lost.

``` python
import sys
import IPython.core.debugger
IPython.core.debugger.Pdb()
print sys.modules['__main__'].__file__
```

The use case for me (personally) occurs when trying to use `ultratb` as a traceback/debugger. When `ColorTB()` is initialized, it breaks my `__main__` code's `__file__` variable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.