# Buggy code
def visit_try_stmt(self, s: TryStmt) -> Type:
    """Type check a try statement."""
    completed_frames = []  # type: List[Frame]
    self.binder.push_frame()
    self.binder.try_frames.add(len(self.binder.frames) - 2)
    self.accept(s.body)
    self.binder.try_frames.remove(len(self.binder.frames) - 2)
    if s.else_body:
        self.accept(s.else_body)
    self.breaking_out = False
    changed, frame_on_completion = self.binder.pop_frame()
    completed_frames.append(frame_on_completion)

    for i in range(len(s.handlers)):
        self.binder.push_frame()
        if s.types[i]:
            t = self.exception_type(s.types[i])
            if s.vars[i]:
                # To support local variables, we make this a definition line,
                # causing assignment to set the variable's type.
                s.vars[i].is_def = True
                self.check_assignment(s.vars[i], self.temp_node(t, s.vars[i]))
        self.accept(s.handlers[i])
        if s.vars[i]:
            # Exception variables are deleted in python 3 but not python 2.
            # But, since it's bad form in python 2 and the type checking
            # wouldn't work very well, we delete it anyway.

            # Unfortunately, this doesn't let us detect usage before the
            # try/except block.
            if self.pyversion[0] >= 3:
                source = s.vars[i].name
            else:
                source = (
                    '(exception variable "{}", which we do not accept '
                    "outside except: blocks even in python 2)".format(s.vars[i].name)
                )
            var = cast(Var, s.vars[i].node)
            var.type = DeletedType(source=source)
            self.binder.cleanse(s.vars[i])

        self.breaking_out = False
        changed, frame_on_completion = self.binder.pop_frame()
        completed_frames.append(frame_on_completion)

    self.binder.update_from_options(completed_frames)

    if s.finally_body:
        self.accept(s.finally_body)


# Traceback (AttributeError)
Traceback (most recent call last):
File "./scripts/mypy", line 6, in <module>
main(__file__)
File "mypy/mypy/main.py", line 50, in main
type_check_only(sources, bin_dir, options)
File "mypy/mypy/main.py", line 94, in type_check_only
python_path=options.python_path)
File "mypy/mypy/build.py", line 210, in build
result = manager.process(initial_states)
File "mypy/mypy/build.py", line 425, in process
next.process()
File "mypy/mypy/build.py", line 930, in process
self.type_checker().visit_file(self.tree, self.tree.path)
File "mypy/mypy/checker.py", line 409, in visit_file
self.accept(d)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 707, in accept
return visitor.visit_try_stmt(self)
File "mypy/mypy/checker.py", line 1732, in visit_try_stmt
self.accept(s.else_body)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 526, in accept
return visitor.visit_block(self)
File "mypy/mypy/checker.py", line 1113, in visit_block
self.accept(s)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 382, in accept
return visitor.visit_func_def(self)
File "mypy/mypy/checker.py", line 594, in visit_func_def
'redefinition with type')
File "mypy/mypy/checker.py", line 2117, in check_subtype
if not is_subtype(subtype, supertype):
File "mypy/mypy/subtypes.py", line 49, in is_subtype
return left.accept(SubtypeVisitor(right, type_parameter_checker))
AttributeError: 'NoneType' object has no attribute 'accept'

# Fixed code
def visit_try_stmt(self, s: TryStmt) -> Type:
    """Type check a try statement."""
    completed_frames = []  # type: List[Frame]
    self.binder.push_frame()
    self.binder.try_frames.add(len(self.binder.frames) - 2)
    self.accept(s.body)
    self.binder.try_frames.remove(len(self.binder.frames) - 2)
    self.breaking_out = False
    changed, frame_on_completion = self.binder.pop_frame()
    completed_frames.append(frame_on_completion)

    for i in range(len(s.handlers)):
        self.binder.push_frame()
        if s.types[i]:
            t = self.exception_type(s.types[i])
            if s.vars[i]:
                # To support local variables, we make this a definition line,
                # causing assignment to set the variable's type.
                s.vars[i].is_def = True
                self.check_assignment(s.vars[i], self.temp_node(t, s.vars[i]))
        self.accept(s.handlers[i])
        if s.vars[i]:
            # Exception variables are deleted in python 3 but not python 2.
            # But, since it's bad form in python 2 and the type checking
            # wouldn't work very well, we delete it anyway.

            # Unfortunately, this doesn't let us detect usage before the
            # try/except block.
            if self.pyversion[0] >= 3:
                source = s.vars[i].name
            else:
                source = (
                    '(exception variable "{}", which we do not accept '
                    "outside except: blocks even in python 2)".format(s.vars[i].name)
                )
            var = cast(Var, s.vars[i].node)
            var.type = DeletedType(source=source)
            self.binder.cleanse(s.vars[i])

        self.breaking_out = False
        changed, frame_on_completion = self.binder.pop_frame()
        completed_frames.append(frame_on_completion)

    # Do the else block similar to the way we do except blocks.
    if s.else_body:
        self.binder.push_frame()
        self.accept(s.else_body)
        self.breaking_out = False
        changed, frame_on_completion = self.binder.pop_frame()
        completed_frames.append(frame_on_completion)

    self.binder.update_from_options(completed_frames)

    if s.finally_body:
        self.accept(s.finally_body)