Search in the importing module's directory, not the current directory

Bug #486957 reported by Matt Giuca
6
This bug affects 1 person
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

Revision history for this message
Matt Giuca (mgiuca) wrote :

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).

Changed in mars:
status: Triaged → In Progress
Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in trunk r917.

Changed in mars:
status: In Progress → Fix Committed
Matt Giuca (mgiuca)
Changed in mars:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.