# Buggy code
def visit_try_stmt(self, s: TryStmt) -> Type:
    """Type check a try statement."""
    # Our enclosing frame will get the result if the try/except falls through.
    # This one gets all possible intermediate states
    with self.binder.frame_context():
        if s.finally_body:
            self.binder.try_frames.add(len(self.binder.frames) - 1)
            breaking_out = self.visit_try_without_finally(s)
            self.binder.try_frames.remove(len(self.binder.frames) - 1)
            # First we check finally_body is type safe for all intermediate frames
            self.accept(s.finally_body)
            breaking_out = breaking_out or self.binder.breaking_out
        else:
            breaking_out = self.visit_try_without_finally(s)

    if not breaking_out and s.finally_body:
        # Then we try again for the more restricted set of options that can fall through
        self.accept(s.finally_body)
    self.binder.breaking_out = breaking_out
    return None


# 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."""
    # Our enclosing frame will get the result if the try/except falls through.
    # This one gets all possible states after the try block exited abnormally
    # (by exception, return, break, etc.)
    with self.binder.frame_context(can_skip=False, fall_through=0):
        # Not only might the body of the try statement exit
        # abnormally, but so might an exception handler or else
        # clause. The finally clause runs in *all* cases, so we
        # need an outer try frame to catch all intermediate states
        # in case an exception is raised during an except or else
        # clause. As an optimization, only create the outer try
        # frame when there actually is a finally clause.
        self.visit_try_without_finally(s, try_frame=bool(s.finally_body))
        if s.finally_body:
            # First we check finally_body is type safe on all abnormal exit paths
            self.accept(s.finally_body)

    if s.finally_body:
        # Then we try again for the more restricted set of options
        # that can fall through. (Why do we need to check the
        # finally clause twice? Depending on whether the finally
        # clause was reached by the try clause falling off the end
        # or exiting abnormally, after completing the finally clause
        # either flow will continue to after the entire try statement
        # or the exception/return/etc. will be processed and control
        # flow will escape. We need to check that the finally clause
        # type checks in both contexts, but only the resulting types
        # from the latter context affect the type state in the code
        # that follows the try statement.)
        self.accept(s.finally_body)

    return None