# Buggy code
def visit_symbol_table(self, symtab: SymbolTable) -> None:
    # Copy the items because we may mutate symtab.
    for key, value in list(symtab.items()):
        cross_ref = value.cross_ref
        if cross_ref is not None:  # Fix up cross-reference.
            del value.cross_ref
            if cross_ref in self.modules:
                value.node = self.modules[cross_ref]
            else:
                stnode = lookup_qualified_stnode(
                    self.modules, cross_ref, self.quick_and_dirty
                )
                if stnode is not None:
                    value.node = stnode.node
                    value.type_override = stnode.type_override
                elif not self.quick_and_dirty:
                    assert stnode is not None, "Could not find cross-ref %s" % (
                        cross_ref,
                    )
        else:
            if isinstance(value.node, TypeInfo):
                # TypeInfo has no accept().  TODO: Add it?
                self.visit_type_info(value.node)
            elif value.node is not None:
                value.node.accept(self)
            if value.type_override is not None:
                value.type_override.accept(self.type_fixer)


# Traceback (AttributeError)
$ mypy --quick --show-traceback a.py
/Users/jukka/src/mypy/b.py:3: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.510-dev-c856a53fe06c0ad9193d86ab35fb86693940f273-dirty
Traceback (most recent call last):
File "/Users/jukka/src/mypy/scripts/mypy", line 6, in <module>
main(__file__)
File "/Users/jukka/src/mypy/mypy/main.py", line 46, in main
res = type_check_only(sources, bin_dir, options)
File "/Users/jukka/src/mypy/mypy/main.py", line 93, in type_check_only
options=options)
File "/Users/jukka/src/mypy/mypy/build.py", line 188, in build
graph = dispatch(sources, manager)
File "/Users/jukka/src/mypy/mypy/build.py", line 1570, in dispatch
process_graph(graph, manager)
File "/Users/jukka/src/mypy/mypy/build.py", line 1813, in process_graph
process_stale_scc(graph, scc, manager)
File "/Users/jukka/src/mypy/mypy/build.py", line 1912, in process_stale_scc
graph[id].type_check_first_pass()
File "/Users/jukka/src/mypy/mypy/build.py", line 1485, in type_check_first_pass
self.type_checker.check_first_pass()
File "/Users/jukka/src/mypy/mypy/checker.py", line 177, in check_first_pass
self.accept(d)
File "/Users/jukka/src/mypy/mypy/checker.py", line 262, in accept
stmt.accept(self)
File "/Users/jukka/src/mypy/mypy/nodes.py", line 823, in accept
return visitor.visit_expression_stmt(self)
File "/Users/jukka/src/mypy/mypy/checker.py", line 1817, in visit_expression_stmt
self.expr_checker.accept(s.expr, allow_none_return=True)
File "/Users/jukka/src/mypy/mypy/checkexpr.py", line 2056, in accept
typ = node.accept(self)
File "/Users/jukka/src/mypy/mypy/nodes.py", line 1254, in accept
return visitor.visit_member_expr(self)
File "/Users/jukka/src/mypy/mypy/checkexpr.py", line 1010, in visit_member_expr
result = self.analyze_ordinary_member_access(e, False)
File "/Users/jukka/src/mypy/mypy/checkexpr.py", line 1025, in analyze_ordinary_member_access
original_type=original_type, chk=self.chk)
File "/Users/jukka/src/mypy/mypy/checkmember.py", line 74, in analyze_member_access
method = info.get_method(name)
AttributeError: 'NoneType' object has no attribute 'get_method'
/Users/jukka/src/mypy/b.py:3: note: use --pdb to drop into pdb

# Fixed code
def visit_symbol_table(self, symtab: SymbolTable) -> None:
    # Copy the items because we may mutate symtab.
    for key, value in list(symtab.items()):
        cross_ref = value.cross_ref
        if cross_ref is not None:  # Fix up cross-reference.
            del value.cross_ref
            if cross_ref in self.modules:
                value.node = self.modules[cross_ref]
            else:
                stnode = lookup_qualified_stnode(
                    self.modules, cross_ref, self.quick_and_dirty
                )
                if stnode is not None:
                    value.node = stnode.node
                    value.type_override = stnode.type_override
                elif not self.quick_and_dirty:
                    assert stnode is not None, "Could not find cross-ref %s" % (
                        cross_ref,
                    )
                else:
                    # We have a missing crossref in quick mode, need to put something
                    value.node = stale_info()
                    if value.type_override is not None:
                        value.type_override.accept(self.type_fixer)
        else:
            if isinstance(value.node, TypeInfo):
                # TypeInfo has no accept().  TODO: Add it?
                self.visit_type_info(value.node)
            elif value.node is not None:
                value.node.accept(self)
            if value.type_override is not None:
                value.type_override.accept(self.type_fixer)