# HG changeset patch # User Paul Boddie # Date 1472939854 -7200 # Node ID ed57140ebc0333e77046571985082f4642c56eff # Parent f836023496a3249ffe77d635eee7121105af48b7 Fixed import statement semantics to always provide the leaf module. Moved name resolution attributes back into the common module abstraction, so that cached modules can be read. Fixed cache-related import in the importer. diff -r f836023496a3 -r ed57140ebc03 importer.py --- a/importer.py Sat Sep 03 22:43:44 2016 +0200 +++ b/importer.py Sat Sep 03 23:57:34 2016 +0200 @@ -24,6 +24,7 @@ from os.path import exists, extsep, getmtime, join from os import listdir, makedirs, remove from common import init_item, readfile, writefile +from modules import CachedModule from referencing import Reference import inspector import sys @@ -633,7 +634,7 @@ module = self.modules.get(module_name) if not module and not self.source_is_new(filename, module_name): - module = inspector.CachedModule(module_name, self) + module = CachedModule(module_name, self) self.add_module(module_name, module) filename = join(self.cache, module_name) diff -r f836023496a3 -r ed57140ebc03 inspector.py --- a/inspector.py Sat Sep 03 22:43:44 2016 +0200 +++ b/inspector.py Sat Sep 03 23:57:34 2016 +0200 @@ -35,8 +35,10 @@ "A module inspector." def __init__(self, name, importer): + + "Initialise the module with basic details." + BasicModule.__init__(self, name, importer) - NameResolving.__init__(self) self.in_class = False self.in_conditional = False @@ -642,7 +644,7 @@ if not alias and len(n.names) > 1: raise InspectError("Imported modules must be aliased unless a simple module is imported.", path, n) - self.set_module(alias or name.split(".")[0], name) + self.set_module(alias or name.split(".")[-1], name) self.importer.queue_module(name, self) def process_invocation_node(self, n): diff -r f836023496a3 -r ed57140ebc03 modules.py --- a/modules.py Sat Sep 03 22:43:44 2016 +0200 +++ b/modules.py Sat Sep 03 23:57:34 2016 +0200 @@ -20,7 +20,7 @@ this program. If not, see . """ -from common import CommonModule +from common import init_item, CommonModule from encoders import decode_modifier_term, encode_modifiers, encode_usage from referencing import decode_reference, Reference from results import ResolvedNameRef @@ -84,6 +84,15 @@ self.attr_access_modifiers = {} + # Name resolution details. + + self.name_references = {} # references to globals + + # Initialisation-related details. + + self.initialised_names = {} + self.aliased_names = {} + def __repr__(self): return "BasicModule(%r, %r)" % (self.name, self.importer) diff -r f836023496a3 -r ed57140ebc03 resolving.py --- a/resolving.py Sat Sep 03 22:43:44 2016 +0200 +++ b/resolving.py Sat Sep 03 23:57:34 2016 +0200 @@ -29,14 +29,6 @@ "Resolving names mix-in for inspected modules." - def __init__(self): - self.name_references = {} # references to globals - - # Initialisation-related details. - - self.initialised_names = {} - self.aliased_names = {} - # Object resolution. def resolve_object(self, ref):