Bug 358398 - Many from-import statements are not properly parsed
Summary: Many from-import statements are not properly parsed
Status: RESOLVED NOT A BUG
Alias: None
Product: kdev-python
Classification: Developer tools
Component: Documentation data (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-23 03:50 UTC by Matt Scheirer
Modified: 2016-01-23 09:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Scheirer 2016-01-23 03:50:10 UTC
While running upstream a lot of from <module> import <object> statements fail to resolve as valid definitions during semantic analysis.

It can be easily demonstrated with the following:

from hashlib import md5
from sys import platform

md5('foo')
platform()

Both are included system modules, where md5 will resolve to "Problem in semantic analysis variable not found: md5" and platform will resolve to "void platform kind variable decl filename -99998".

For md5 it does not recognize the import at all, and in the later case the semantic analysis seems to be declaring backwards rather than on line 2. Switching the ordering has no impact, though - a few modules work with mangled line definitions, but most fail to be recognized. Importing the module and calling through its name works fine:

import hashlib
hashlib.md5('foo')

This bug also occurs in the beta release 4.90.90. Arch does not package kdev-python for the current stable release so I did not test it there. This is all on Python 3, and I discovered it while checking out a Flask project to hack on and discovering almost all the from imports were broken. Kind of a bummer since the major reason to use kdev for python is the semantic analysis!
Comment 1 Matt Scheirer 2016-01-23 04:15:09 UTC
Something else is going on here that I'm going to look into more. For one, that isn't even valid Python syntax (durr platform isn't a function, but thats unrelated to what I was experiencing honestly). I think the real bug is that the parser is running in the background on all site-packages for a very long time (hence it gets through hashlib and gets stuck before sys) and doesn't actually show it in the progress docket. I let it sit for two hours and now I'm getting proper resolution of from-import statements again.
Comment 2 Sven Brauch 2016-01-23 09:04:20 UTC
Yes, the import handling is a bit quirky in quite a lot of cases. :/
If you find any reproducable issues, please report them into one bug each and I'll try to look into them as soon as I find the time.
I also noticed the progress bar for the background parser is not working in recent versions of kdevplatform, or at least it has a very long delay until it actually shows up. I can't find a change which introduces this behaviour, not sure why it is like this now.
Comment 3 Sven Brauch 2016-01-23 09:06:14 UTC
Also is two hours really the time it takes? Should be a few minutes at most, and that is to be expected and can't really be changed. It will be cached for the next start of kdevelop though.