1.1 --- a/micropython/inspect.py Tue Jul 10 01:36:34 2012 +0200
1.2 +++ b/micropython/inspect.py Tue Jul 10 18:54:33 2012 +0200
1.3 @@ -111,19 +111,19 @@
1.4
1.5 self.optimisations = self.importer.optimisations
1.6 self.builtins = self.importer.modules.get("__builtins__")
1.7 - self.loaded = 0
1.8 - self.completed = 0
1.9 + self.loaded = False
1.10 + self.completed = False
1.11
1.12 # Current expression state.
1.13
1.14 self.expr = None
1.15 - self.in_assignment = 0 # For slice and subscript handling.
1.16 + self.in_assignment = False # For slice and subscript handling.
1.17
1.18 # Namespace state.
1.19
1.20 - self.in_method = 0 # Find instance attributes in all methods.
1.21 - self.in_function = 0 # Note function presence, affecting definitions.
1.22 - self.in_loop = 0 # Note loop "membership", affecting assignments.
1.23 + self.in_method = False # Find instance attributes in all methods.
1.24 + self.in_function = False # Note function presence, affecting definitions.
1.25 + self.in_loop = False # Note loop "membership", affecting assignments.
1.26 self.namespaces = []
1.27 self.functions = []
1.28
1.29 @@ -139,7 +139,7 @@
1.30
1.31 def complete(self):
1.32 if not self.completed:
1.33 - self.completed = 1
1.34 + self.completed = True
1.35 self.process()
1.36 if self.importer.verbose:
1.37 print >>sys.stderr, "Completed import of", self.full_name()
1.38 @@ -794,19 +794,19 @@
1.39 # Previous namespace is the class.
1.40
1.41 if self.in_class(namespaces):
1.42 - self.in_method = 1
1.43 + self.in_method = True
1.44
1.45 in_function = self.in_function
1.46 in_loop = self.in_loop
1.47 - self.in_function = 1
1.48 - self.in_loop = 0
1.49 + self.in_function = True
1.50 + self.in_loop = False
1.51
1.52 self.namespaces = namespaces
1.53 self.dispatch(node.code)
1.54
1.55 self.in_loop = in_loop
1.56 self.in_function = in_function
1.57 - self.in_method = 0
1.58 + self.in_method = False
1.59
1.60 # Specific handler methods.
1.61
1.62 @@ -818,10 +818,10 @@
1.63
1.64 def visitAssign(self, node):
1.65 self.expr = self.dispatch(node.expr)
1.66 - self.in_assignment = 1
1.67 + self.in_assignment = True
1.68 for n in node.nodes:
1.69 self.dispatch(n)
1.70 - self.in_assignment = 0
1.71 + self.in_assignment = False
1.72
1.73 def visitAssAttr(self, node):
1.74 expr = self.dispatch(node.expr)
1.75 @@ -1061,7 +1061,7 @@
1.76 self.use_name("StopIteration")
1.77
1.78 in_loop = self.in_loop
1.79 - self.in_loop = 1
1.80 + self.in_loop = True
1.81 self.dispatch(node.list)
1.82
1.83 # NOTE: Could generate AST nodes for the actual operations instead of
1.84 @@ -1249,7 +1249,7 @@
1.85 self.use_name("next")
1.86
1.87 in_loop = self.in_loop
1.88 - self.in_loop = 1
1.89 + self.in_loop = True
1.90 self.dispatch(node.list)
1.91
1.92 # NOTE: Could generate AST nodes for the actual operations instead of
1.93 @@ -1409,7 +1409,7 @@
1.94 # Propagate attribute usage to branches.
1.95
1.96 in_loop = self.in_loop
1.97 - self.in_loop = 1
1.98 + self.in_loop = True
1.99
1.100 # The test is evaluated initially and again in the loop.
1.101