bblfsh / python-driver

GNU General Public License v3.0
10 stars 16 forks source link

Alias error in imports [BUG] #197

Closed r0mainK closed 5 years ago

r0mainK commented 5 years ago

Hey !

So I was coding the extractor for the imports, when checking my results I found something strange. First off, a number of canonical libraries, such as os, numpy or sys, were stamped as Aliases, and had the following aspect:

RuntimeImport{
  Path: Alias{
    Name: Identifier{ Name: "sys" }
    Node: {}
  }
}

While this in it of itself is not so much of an issue, as I can just check if the Node attribute is empty then opt to use the Name attribute, the following is more annoying. Basically, given the following import:

import os as _os

I get the following:

RuntimeImport{
  Path: Alias{
    Name: Identifier{ Name: "os" }
    Node: Identifier { Name: "_os" }
  }
}

Which, unless there was an error in this comment seems to be the opposite of what should be expected.

In all cases, I'm guessing there might be some link between both errors, so only opened one issue. I checked on all Python files I had in gitbase, from what I saw:

Note: I used the latest release of the Python client to get this, got the same results when using play.bblf.sh to check it wasn't just me.

dennwc commented 5 years ago

Sorry, I should have checked the driver code more carefully.

Will submit the fix ASAP.