The following forum message was posted by rsflux at http://sourceforge.net/projects/pydev/forums/forum/293649/topic/4652696:
PyDev appears to be incorrectly parsing a file (with Grammar Version set to
3.0) with the 2.* rules for local imports. I'm posting here to make sure this
isn't a known issue; if I get the OK, I'll post an issue in the bug tracker.
To reproduce, set up a project with this relationship:
main.py
pkg (folder)
-> __init__.py
-> foo.py (Contains:
import math
print(math.pi)
)
-> math.py (empty file)
If foo.py attempts to "import math", PyDev thinks that the interpreter is going
to import pkg.math, instead of the built in math module. This is correct in
Python 2.*, but is no longer the case in 3.* (see PEP 328 here
http://www.python.org/dev/peps/pep-0328/). Because of this error, any uses of
the math symbol within foo.py, such getting the .pi attribute, gets tagged with
an "Undefined variable from import" error. Auto-completion and go to definition
functionality is also broken.
As a fix, when a PyDev project is in 3.0 Grammar mode, it should always use
absolute paths in imports except when using the dot syntax (from .math import
something).
Thoughts?
-Ryan
|