davidhalter/jedi — pull request #156 by tkf (2013-03-12 12:16:11+00:00)
Title: Make VIRTUAL_ENV actually importable

I had this strange error when I run ``py.test`` instead of ``tox``:

```
name = 'site-packages.numpy.core.umath'
path = '/home/takafumi/.virtualenvs/mypy/lib/python2.7'

def load_module(name, path):
if path:
self.sys_path.insert(0, path)

temp, sys.path = sys.path, self.sys_path
content = {}
try:
> exec_function('import %s as module' % name, content)

jedi/builtin.py:90:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

source = 'import site-packages.numpy.core.umath as module'
global_map = {'__builtins__': {'ArithmeticError': , 'AssertionError': , 'AttributeError': , 'BaseException': , ...}}

> ???
E File "", line 1
E import site-packages.numpy.core.umath as module
E ^
E SyntaxError: invalid syntax

blub:2: SyntaxError
================= 1 failed, 40 passed, 1 skipped in 6.88 seconds =================
py.test test/test_regression.py 7.26s user 0.18s system 95% cpu 7.802 total
```

It turned out that this is because `sys.path` is used in `BuiltinModule.module` when searching for module. As we are using real import machinery for builtin module, I think we should just add it to `sys.path` rather than Jedi's internal copy.