1.1 --- a/micropython/common.py Sat Jul 14 17:42:42 2012 +0200
1.2 +++ b/micropython/common.py Sat Jul 14 20:38:19 2012 +0200
1.3 @@ -19,9 +19,9 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from micropython.data import Attr, Instance, UnresolvedName
1.8 +from compiler.ast import Class, Function, Module
1.9 +from micropython.data import Attr
1.10 from micropython.errors import *
1.11 -import sys
1.12
1.13 try:
1.14 set
1.15 @@ -55,7 +55,7 @@
1.16
1.17 # NOTE: Should perhaps specialise the subclasses appropriately.
1.18
1.19 - if hasattr(self, "unit"):
1.20 + if isinstance(self, (Class, Function, Module)):
1.21 exc.unit_name = self.unit.full_name()
1.22 else:
1.23 exc.unit_name = self.full_name()
1.24 @@ -79,13 +79,13 @@
1.25 # not that of a general instance or an unresolved name, attempt to
1.26 # identify it.
1.27
1.28 - if hasattr(node, "_attr") and isinstance(node._attr, Attr):
1.29 + if node._attr and isinstance(node._attr, Attr):
1.30 attr = node._attr
1.31 target_names.add((attr.parent.full_name(), attr.is_static_attribute()))
1.32
1.33 # Otherwise, attempt to employ the attribute usage observations.
1.34
1.35 - elif hasattr(node, "_attrusers"):
1.36 + elif node._attrusers:
1.37
1.38 # Visit each attribute user.
1.39
1.40 @@ -111,7 +111,7 @@
1.41 program unit within which it is found.
1.42 """
1.43
1.44 - return hasattr(node, "unit") and node.unit.parent.has_key(node.unit.name)
1.45 + return node.unit and node.unit.parent.has_key(node.unit.name)
1.46
1.47 # Useful data.
1.48