1.1 --- a/annotate.py Wed Feb 14 21:57:46 2007 +0100
1.2 +++ b/annotate.py Wed Feb 14 23:35:19 2007 +0100
1.3 @@ -131,7 +131,7 @@
1.4 types possible when the means of constructing the namespace may depend on
1.5 run-time behaviour.
1.6
1.7 - Covered: Assign, CheckExc, Conditional, Global, Import, InvokeBlock,
1.8 + Covered: Assign, CheckType, Conditional, Global, Import, InvokeBlock,
1.9 InvokeFunction, LoadAttr, LoadExc, LoadName, LoadRef, LoadTemp,
1.10 Module, Not, Pass, Raise, ReleaseTemp, ReturnFromBlock,
1.11 ReturnFromFunction, StoreAttr, StoreName, StoreTemp, Subprogram,
1.12 @@ -286,25 +286,27 @@
1.13 assign.code = self.dispatches(assign.code)
1.14 return assign
1.15
1.16 - def visitCheckExc(self, checkexc):
1.17 + def visitCheckType(self, checktype):
1.18
1.19 """
1.20 - Return the 'checkexc' node, processing the expression to find the
1.21 + Return the 'checktype' node, processing the expression to find the
1.22 possible types of the exception, and processing each choice to build a
1.23 list of checked types for the exception.
1.24 """
1.25
1.26 - checkexc.expr = self.dispatch(checkexc.expr)
1.27 + inverted = getattr(checktype, "inverted", 0)
1.28 + checktype.expr = self.dispatch(checktype.expr)
1.29 expr_types = self.namespace.types
1.30 choice_types = []
1.31 choices = []
1.32 - for choice in checkexc.choices:
1.33 + for choice in checktype.choices:
1.34 choices.append(self.dispatch(choice))
1.35 choice_types += self.namespace.types
1.36 for expr_type in expr_types:
1.37 - if expr_type.type.get_class() not in choice_types:
1.38 - self._prune_non_accesses(checkexc.expr, expr_type)
1.39 - return checkexc
1.40 + in_choices = expr_type.type.get_class() in choice_types
1.41 + if not inverted and not in_choices or inverted and in_choices:
1.42 + self._prune_non_accesses(checktype.expr, expr_type)
1.43 + return checktype
1.44
1.45 def visitConditional(self, conditional):
1.46