1.1 --- a/micropython/__init__.py Sun Apr 26 03:24:12 2009 +0200
1.2 +++ b/micropython/__init__.py Sun Apr 26 18:02:56 2009 +0200
1.3 @@ -416,10 +416,9 @@
1.4
1.5 # Name records (used to track actual use of names).
1.6 # Include names which may not be explicitly used in programs.
1.7 - # NOTE: Potentially declare these when inspecting. For example, __iter__
1.8 - # NOTE: and next are usually implicitly invoked by "for" statements.
1.9 + # NOTE: Potentially declare these when inspecting.
1.10
1.11 - self.names_used = set(["__init__", "__call__", "__getitem__", "__bool__", "__iter__", "next"])
1.12 + self.names_used = set(["__init__", "__call__", "__bool__"])
1.13
1.14 # Status information.
1.15
2.1 --- a/micropython/inspect.py Sun Apr 26 03:24:12 2009 +0200
2.2 +++ b/micropython/inspect.py Sun Apr 26 18:02:56 2009 +0200
2.3 @@ -406,6 +406,13 @@
2.4 return None
2.5
2.6 def visitAssList(self, node):
2.7 +
2.8 + # Declare names which will be used by generated code.
2.9 +
2.10 + self.importer.use_name("__getitem__")
2.11 +
2.12 + # Process the assignment.
2.13 +
2.14 for i, n in enumerate(node.nodes):
2.15 self.dispatch(n)
2.16 self.importer.make_constant(i) # for __getitem__(i) at run-time
2.17 @@ -539,6 +546,14 @@
2.18 visitFloorDiv = _visitBinary
2.19
2.20 def visitFor(self, node):
2.21 +
2.22 + # Declare names which will be used by generated code.
2.23 +
2.24 + self.importer.use_name("__iter__")
2.25 + self.importer.use_name("next")
2.26 +
2.27 + # Enter the loop.
2.28 +
2.29 self.in_loop = 1
2.30 self.NOP(node)
2.31 self.in_loop = 0