# Buggy code
def visit_try_without_finally(self, s: TryStmt) -> bool:
    """Type check a try statement, ignoring the finally block.

    Return whether we are guaranteed to be breaking out.
    Otherwise, it will place the results possible frames of
    that don't break out into self.binder.frames[-2].
    """
    breaking_out = True
    # This frame records the possible states that exceptions can leave variables in
    # during the try: block
    with self.binder.frame_context():
        with self.binder.frame_context(3):
            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)
        breaking_out = breaking_out and self.binder.last_pop_breaking_out
        for i in range(len(s.handlers)):
            with self.binder.frame_context(3):
                if s.types[i]:
                    t = self.visit_except_handler_test(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.options.python_version[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])
            breaking_out = breaking_out and self.binder.last_pop_breaking_out
    return breaking_out


# 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_without_finally(self, s: TryStmt, try_frame: bool) -> None:
    """Type check a try statement, ignoring the finally block.

    On entry, the top frame should receive all flow that exits the
    try block abnormally (i.e., such that the else block does not
    execute), and its parent should receive all flow that exits
    the try block normally.
    """
    # This frame will run the else block if the try fell through.
    # In that case, control flow continues to the parent of what
    # was the top frame on entry.
    with self.binder.frame_context(can_skip=False, fall_through=2, try_frame=try_frame):
        # This frame receives exit via exception, and runs exception handlers
        with self.binder.frame_context(can_skip=False, fall_through=2):
            # Finally, the body of the try statement
            with self.binder.frame_context(
                can_skip=False, fall_through=2, try_frame=True
            ):
                self.accept(s.body)
            for i in range(len(s.handlers)):
                with self.binder.frame_context(can_skip=True, fall_through=4):
                    if s.types[i]:
                        t = self.visit_except_handler_test(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.options.python_version[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])
        if s.else_body:
            self.accept(s.else_body)