MCPcopy Create free account
hub / github.com/datacamp/pythonwhat / visit_Try

Method visit_Try

pythonwhat/parsing.py:810–831  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

808 self.out = []
809
810 def visit_Try(self, node):
811 handlers = {}
812
813 for handler in node.handlers:
814 if isinstance(handler.type, ast.Tuple):
815 # of form -- except TypeError, KeyError
816 for el in handler.type.elts:
817 handlers[el.id] = self.parse_handler(handler)
818 else:
819 # either general handler, or single error handler
820 k = "all" if not handler.type else self.get_identifier(handler.type)
821 handlers[k] = self.parse_handler(handler)
822
823 self.out.append(
824 {
825 "node": node,
826 "body": node.body,
827 "orelse": node.orelse or None,
828 "finalbody": node.finalbody or None,
829 "handlers": handlers,
830 }
831 )
832
833 @staticmethod
834 def get_identifier(obj):

Callers

nothing calls this directly

Calls 2

parse_handlerMethod · 0.95
get_identifierMethod · 0.95

Tested by

no test coverage detected