Menu

Error with 3.* grammar and local imports

Ryan Seiff
2011-08-12
2013-03-15
  • Ryan Seiff

    Ryan Seiff - 2011-08-12

    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

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-08-18

    Yeap, seems like a bug to me. Please report it in the bugtracker (you can reference this thread if you want).

    Cheers,

    Fabio

     
  • atthecorner

    atthecorner - 2011-08-31

    I just encountered this apparently as a  consequence of updating to pydev version 2.2.2.2011082312.
    I have been using Version  2.2.0.2011062419 for a few months without trouble. It has been good enough for my purposes. I have been searching for an archive site so I could download/update the version that works for well enough for me. I haven't found one yet. Is there such a site?

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-09-01

    The update site (http://pydev.org/updates) has archives (in the install dialog you have an option to show old versions).

    Cheers,

    Fabio

     
  • atthecorner

    atthecorner - 2011-09-01

    I never had to use the archives before now, which says a lot.
    Thanks,
    -m

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-09-01

    Just to note, I'm working on this issue now, so, if you wait until tomorrow, there should be a nightly build with this fixed.

    Cheers,

    Fabio

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.