1.1 --- a/lib/builtins.py Sun Jun 06 15:27:50 2010 +0200
1.2 +++ b/lib/builtins.py Sat Jun 12 01:04:32 2010 +0200
1.3 @@ -367,7 +367,12 @@
1.4 def input(prompt=None): pass
1.5 def isinstance(obj, cls_or_tuple): pass
1.6 def issubclass(obj, cls_or_tuple): pass
1.7 -def iter(collection_or_callable, sentinel=None): pass
1.8 +
1.9 +def iter(collection):
1.10 +
1.11 + "Implementation of iter without callable plus sentinel support."
1.12 +
1.13 + return collection.__iter__()
1.14
1.15 def len(obj):
1.16
2.1 --- a/micropython/inspect.py Sun Jun 06 15:27:50 2010 +0200
2.2 +++ b/micropython/inspect.py Sat Jun 12 01:04:32 2010 +0200
2.3 @@ -899,6 +899,7 @@
2.4
2.5 if self.importer.predefined_constants.has_key(name):
2.6 attr = self.importer.get_predefined_constant(name)
2.7 + node._scope = "constant"
2.8
2.9 # Locals.
2.10
2.11 @@ -908,6 +909,7 @@
2.12 # Note usage of the local (potentially a class attribute).
2.13
2.14 self.use_specific_attribute(None, name)
2.15 + node._scope = "local"
2.16
2.17 # Globals.
2.18
2.19 @@ -917,18 +919,21 @@
2.20 # Note usage of the module attribute.
2.21
2.22 self.use_specific_attribute(self.full_name(), name)
2.23 + node._scope = "global"
2.24
2.25 # Builtins.
2.26
2.27 elif self.builtins is not None and self.builtins.has_key(name):
2.28 attr = self.builtins[name]
2.29 self.use_specific_attribute(self.builtins.full_name(), name)
2.30 + node._scope = "builtins"
2.31
2.32 # Unknown.
2.33
2.34 else:
2.35 attr = None
2.36 self.use_name(name)
2.37 + node._scope = "unknown"
2.38
2.39 return attr
2.40
3.1 --- a/micropython/trans.py Sun Jun 06 15:27:50 2010 +0200
3.2 +++ b/micropython/trans.py Sat Jun 12 01:04:32 2010 +0200
3.3 @@ -1164,7 +1164,14 @@
3.4 """
3.5
3.6 name = node.name
3.7 - scope = self.get_scope(name)
3.8 +
3.9 + # Transfer scope information if this was set during inspection.
3.10 +
3.11 + if hasattr(node, "_scope"):
3.12 + scope = node._scope
3.13 + else:
3.14 + scope = self.get_scope(name)
3.15 +
3.16 #print self.module.name, node.lineno, name, scope
3.17 self._generateName(name, scope, classes, node)
3.18
4.1 --- a/tests/xrange.py Sun Jun 06 15:27:50 2010 +0200
4.2 +++ b/tests/xrange.py Sat Jun 12 01:04:32 2010 +0200
4.3 @@ -4,5 +4,7 @@
4.4 result_0 = xr.start
4.5 result_10 = xr.end
4.6 result_1 = xr.step
4.7 +iter = iter(xr)
4.8 +result1_0 = iter.next()
4.9
4.10 # vim: tabstop=4 expandtab shiftwidth=4