inducer / inducer/pudb

pudb isn't compatible w/ mercurial.demandimport

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

Description

Mercurial has a magical import wrapper called demandimport.

``` py
import mercurial
import mercurial.demandimport
mercurial.demandimport.enable()
import foo
```

if foo does not exist, it will not throw an exception at this point.
Instead, it will throw its exception when you do:

``` py
foo.bar
```

I realized this when using **py3** (not **IronPython**) w/ mercurial.demandimport and **pudb3**:

``` py
>>> ctypes.util
Traceback (most recent call last):
File "/home/timeless/hg/py3/lib/python3.5/site-packages/pudb/debugger.py", line 1415, in
cmdline_get_namespace
from pudb.shell import SetPropagatingDict
File "/home/timeless/hg/crew/mercurial/demandimport.py", line 143, in _demandimport
return _hgextimport(_import, name, globals, locals, fromlist, level)
File "/home/timeless/hg/crew/mercurial/demandimport.py", line 53, in _hgextimport
return importfunc(name, globals, *args, **kwargs)
File "/home/timeless/hg/py3/lib/python3.5/site-packages/pudb/shell.py", line 183, in
if HAVE_IPYTHON and hasattr(IPython, 'Shell'):
File "/home/timeless/hg/crew/mercurial/demandimport.py", line 132, in __getattribute__
self._load()
File "/home/timeless/hg/crew/mercurial/demandimport.py", line 98, in _load
mod = _hgextimport(_import, head, globals, locals, None, level)
File "/home/timeless/hg/crew/mercurial/demandimport.py", line 53, in _hgextimport
return importfunc(name, globals, *args, **kwargs)
ImportError: No module named 'IPython'
```

The fix for this sort of thing is to access a property of each module inside the try block that intends to import the module. I'll try to write a PR for this, but first I'll need to find out what properties IPython has (and probably try installing it...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.