Search in the importing module's directory, not the current directory
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Fix Released
|
Low
|
Matt Giuca |
Bug Description
When importing modules (via the 'import' statement), Mars currently looks in the current directory, then MARSPATH, then some fixed search paths (as specified in the Mars documentation, "The top level"). This algorithm is somewhat flawed. It means that imported modules (from a directory other than the current) will have their imported modules shadowed by files in the current directory.
This should be changed so that step #1 is to look in the importing module’s directory, not the current directory. This means that modules can *not* import other modules in the current directory, unless '.' is explicitly added to MARSPATH. I think that's a good thing -- it's confusing for a module to have access to files just because they happen to be in the current directory, but the behaviour can be overridden.
Related branches
Changed in mars: | |
status: | Fix Committed → Fix Released |
I can't write a test case for this, because the test framework always cds into the directory containing the Mars file before testing it (no way to write a test case that would fail even if this bug was unfixed).