1.1 --- a/micropython/__init__.py Fri Aug 20 01:43:51 2010 +0200
1.2 +++ b/micropython/__init__.py Sat Aug 21 02:45:58 2010 +0200
1.3 @@ -730,9 +730,15 @@
1.4 package exists.
1.5 """
1.6
1.7 + if return_leaf:
1.8 + name_for_return = name
1.9 + else:
1.10 + name_for_return = name.split(".")[0]
1.11 +
1.12 if self.modules.has_key(name) and self.modules[name].loaded:
1.13 #print "Cached (%s)" % name
1.14 - return self.modules[name]
1.15 + return self.modules[name_for_return]
1.16 +
1.17 if self.verbose:
1.18 print "Loading", name
1.19
2.1 --- a/micropython/data.py Fri Aug 20 01:43:51 2010 +0200
2.2 +++ b/micropython/data.py Sat Aug 21 02:45:58 2010 +0200
2.3 @@ -143,7 +143,8 @@
2.4 return self.items() + self.lambdas.items()
2.5
2.6 def vacuum_item(self, name):
2.7 - del self[name]
2.8 + if self.has_key(name):
2.9 + del self[name]
2.10
2.11 def add_lambda(self, obj):
2.12 attr = Attr(None, self, obj.name)
2.13 @@ -1317,7 +1318,7 @@
2.14 self.allattr.update(self.all_class_attributes())
2.15 for name, attr in self.instance_attributes().items():
2.16 if self.allattr.has_key(name):
2.17 - print "Instance attribute %r in %r overrides class attribute." % (name, self)
2.18 + print "Warning: instance attribute %r in %r overrides class attribute." % (name, self)
2.19 self.allattr[name] = attr
2.20 return self.allattr
2.21
2.22 @@ -1603,11 +1604,14 @@
2.23 def add_descendant(self, cls):
2.24 self.descendants.add(cls)
2.25
2.26 - def all_class_attributes(self):
2.27 + def all_attributes(self):
2.28 return {}
2.29
2.30 - def instance_attributes(self):
2.31 - return {}
2.32 + def all_attribute_names(self):
2.33 + return []
2.34 +
2.35 + all_class_attributes = class_attributes = instance_attributes = all_attributes
2.36 + all_class_attribute_names = class_attribute_names = instance_attribute_names = all_attribute_names
2.37
2.38 def __repr__(self):
2.39 return "UnresolvedName(%r, %r)" % (self.name, self.parent_name)
3.1 --- a/micropython/inspect.py Fri Aug 20 01:43:51 2010 +0200
3.2 +++ b/micropython/inspect.py Sat Aug 21 02:45:58 2010 +0200
3.3 @@ -573,14 +573,16 @@
3.4 self.expr = self.dispatch(node.expr)
3.5
3.6 # NOTE: Similar to micropython.ast handler code.
3.7 - # NOTE: Slices and subscripts not supported.
3.8 + # NOTE: Slices and subscripts are supported by __setitem__(slice) and
3.9 + # NOTE: not __setslice__.
3.10
3.11 if isinstance(node.node, compiler.ast.Name):
3.12 self.visitAssName(node.node)
3.13 elif isinstance(node.node, compiler.ast.Getattr):
3.14 self.visitAssAttr(node.node)
3.15 else:
3.16 - raise InspectError("AugAssign(Slice or Subscript)")
3.17 + self.use_specific_attribute("__builtins__", "slice")
3.18 + self.use_name("__setitem__", node)
3.19
3.20 return None
3.21
3.22 @@ -604,7 +606,7 @@
3.23 """
3.24
3.25 if self.namespaces:
3.26 - print "Class %r in %r is not global: ignored." % (node.name, self.namespaces[-1].full_name())
3.27 + print "Warning: class %r in %r is not global: ignored." % (node.name, self.namespaces[-1].full_name())
3.28 return None
3.29 else:
3.30 if self.in_loop:
4.1 --- a/micropython/report.py Fri Aug 20 01:43:51 2010 +0200
4.2 +++ b/micropython/report.py Sat Aug 21 02:45:58 2010 +0200
4.3 @@ -251,7 +251,7 @@
4.4
4.5 def _assname(self, name, node):
4.6 self._span_start("assname")
4.7 - if hasattr(node, "_attrnames") and node._attrnames[name]:
4.8 + if hasattr(node, "_attrnames") and node._attrnames.get(name):
4.9 attrnames = node._attrnames[name]
4.10 self._name_start()
4.11 self.stream.write(name)
4.12 @@ -370,8 +370,8 @@
4.13
4.14 if attrs:
4.15 for attr in attrs:
4.16 - value = attr.get_value()
4.17 - if value is not None:
4.18 + if attr.is_strict_constant():
4.19 + value = attr.get_value()
4.20 self.stream.write("<td class='summary-class-attr' id='%s'>" % self._attr(value.full_name()))
4.21 self._object_name_ref(self.module, value, classes="summary-ref")
4.22 self.stream.write("</td>\n")
4.23 @@ -534,7 +534,7 @@
4.24 self._name(node.modname)
4.25 self._keyword("import", 1)
4.26 first = 1
4.27 - for (name, alias), _name in map(None, node.names, node._names):
4.28 + for name, alias in node.names:
4.29 if not first:
4.30 self.stream.write(", ")
4.31 if alias:
4.32 @@ -657,7 +657,8 @@
4.33 def visitRaise(self, node):
4.34 self.stream.write("<div class='raise nowrap'>\n")
4.35 self._keyword("raise")
4.36 - self.dispatch(node.expr1)
4.37 + if node.expr1 is not None:
4.38 + self.dispatch(node.expr1)
4.39 if node.expr2 is not None:
4.40 self.stream.write(",\n")
4.41 self.dispatch(node.expr2)
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/tests/importer_package.py Sat Aug 21 02:45:58 2010 +0200
5.3 @@ -0,0 +1,7 @@
5.4 +#!/usr/bin/env python
5.5 +
5.6 +import imported_package
5.7 +
5.8 +result_123 = imported_package.attribute
5.9 +
5.10 +# vim: tabstop=4 expandtab shiftwidth=4
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/tests/importer_package_local.py Sat Aug 21 02:45:58 2010 +0200
6.3 @@ -0,0 +1,10 @@
6.4 +#!/usr/bin/env python
6.5 +
6.6 +import imported_package
6.7 +
6.8 +def f():
6.9 + return imported_package.attribute
6.10 +
6.11 +result_123 = f()
6.12 +
6.13 +# vim: tabstop=4 expandtab shiftwidth=4
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/tests/importer_package_module.py Sat Aug 21 02:45:58 2010 +0200
7.3 @@ -0,0 +1,7 @@
7.4 +#!/usr/bin/env python
7.5 +
7.6 +import imported_package.module
7.7 +
7.8 +result_456 = imported_package.module.attribute
7.9 +
7.10 +# vim: tabstop=4 expandtab shiftwidth=4
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/tests/importer_package_module_local.py Sat Aug 21 02:45:58 2010 +0200
8.3 @@ -0,0 +1,10 @@
8.4 +#!/usr/bin/env python
8.5 +
8.6 +import imported_package.module
8.7 +
8.8 +def f():
8.9 + return imported_package.module.attribute
8.10 +
8.11 +result_456 = f()
8.12 +
8.13 +# vim: tabstop=4 expandtab shiftwidth=4