Commits

Ali Gholami Rudi  committed 7c35b1b

objectinfer: handling multiple exceptions in except blocks

  • Participants
  • Parent commits eec4abf

Comments (0)

Files changed (2)

File rope/base/pyobjectsdef.py

             ast.walk(child, self)
 
     def _excepthandler(self, node):
-        if node.name and isinstance(node.name, ast.Name) and \
-           node.type and isinstance(node.type, ast.Name):
+        if node.name is not None and isinstance(node.name, ast.Name):
+            type_node = node.type
+            if isinstance(node.type, ast.Tuple) and type_node.elts:
+                type_node = type_node.elts[0]
             pynames = rope.base.evaluate._get_evaluated_names(
-                node.name, node.type, lineno=node.lineno,
+                node.name, type_node, lineno=node.lineno,
                 module=self.get_module(), eval_type=True)
             self.names.update(pynames)
 

File ropetest/objectinfertest.py

         e_var = mod['e'].get_object()
         self.assertEquals(my_error, e_var.get_type())
 
-    # TODO: handling catching multiple exceptions
-    def xxx_test_we_know_the_type_of_catched_exceptions_with_multiple_excepts(self):
+    def test_we_know_the_type_of_catched_multiple_excepts(self):
         mod = self.pycore.get_string_module(
             'class MyError(Exception):\n    pass\n'
             'try:\n    raise MyError()\n'