# Buggy code
def __init__(
    self,
    pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION,
    is_stub_file: bool = False,
) -> None:
    self.map = [self.unknown_character] * 256
    self.tok = []
    self.indents = [0]
    self.open_brackets = []
    self.pyversion = pyversion
    self.is_stub_file = is_stub_file
    self.ignored_lines = set()
    # Fill in the map from valid character codes to relevant lexer methods.
    extra_misc = "" if pyversion[0] >= 3 else "`"
    for seq, method in [
        ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", self.lex_name),
        ("abcdefghijklmnopqrstuvwxyz_", self.lex_name),
        ("0123456789", self.lex_number),
        (".", self.lex_number_or_dot),
        (" " + "\t" + "\x0c", self.lex_space),
        ('"', self.lex_str_double),
        ("'", self.lex_str_single),
        ("\r" + "\n", self.lex_break),
        (";", self.lex_semicolon),
        (":", self.lex_colon),
        ("#", self.lex_comment),
        ("\\", self.lex_backslash),
        ("([{", self.lex_open_bracket),
        (")]}", self.lex_close_bracket),
        ("-+*/<>%&|^~=!,@" + extra_misc, self.lex_misc),
    ]:
        for c in seq:
            self.map[ord(c)] = method
    if pyversion[0] == 2:
        self.keywords = keywords_common | keywords2
        # Decimal/hex/octal/binary literal or integer complex literal
        self.number_exp1 = re.compile("(0[xXoObB][0-9a-fA-F]+|[0-9]+)[lL]?")

    if pyversion[0] == 3:
        self.keywords = keywords_common | keywords3
        self.number_exp1 = re.compile("0[xXoObB][0-9a-fA-F]+|[0-9]+")


# Traceback (IndexError)
Traceback (most recent call last):
File "/usr/local/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/guido/src/mypy/mypy/__main__.py", line 5, in <module>
main(None)
File "/Users/guido/src/mypy/mypy/main.py", line 53, in main
type_check_only(sources, bin_dir, options)
File "/Users/guido/src/mypy/mypy/main.py", line 96, in type_check_only
python_path=options.python_path)
File "/Users/guido/src/mypy/mypy/build.py", line 203, in build
result = manager.process(initial_states)
File "/Users/guido/src/mypy/mypy/build.py", line 386, in process
next.process()
File "/Users/guido/src/mypy/mypy/build.py", line 710, in process
tree = self.parse(self.program_text, self.path)
File "/Users/guido/src/mypy/mypy/build.py", line 807, in parse
custom_typing_module=self.manager.custom_typing_module)
File "/Users/guido/src/mypy/mypy/parse.py", line 83, in parse
tree = parser.parse(source)
File "/Users/guido/src/mypy/mypy/parse.py", line 130, in parse
is_stub_file=self.is_stub_file)
File "/Users/guido/src/mypy/mypy/lex.py", line 170, in lex
l.lex(string, first_line)
File "/Users/guido/src/mypy/mypy/lex.py", line 377, in lex
map[c]()
IndexError: list index out of range

# Fixed code
def __init__(
    self,
    pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION,
    is_stub_file: bool = False,
) -> None:
    self.map = {}
    self.tok = []
    self.indents = [0]
    self.open_brackets = []
    self.pyversion = pyversion
    self.is_stub_file = is_stub_file
    self.ignored_lines = set()
    # Fill in the map from valid character codes to relevant lexer methods.
    extra_misc = "" if pyversion[0] >= 3 else "`"
    for seq, method in [
        ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", self.lex_name),
        ("abcdefghijklmnopqrstuvwxyz_", self.lex_name),
        ("0123456789", self.lex_number),
        (".", self.lex_number_or_dot),
        (" " + "\t" + "\x0c", self.lex_space),
        ('"', self.lex_str_double),
        ("'", self.lex_str_single),
        ("\r" + "\n", self.lex_break),
        (";", self.lex_semicolon),
        (":", self.lex_colon),
        ("#", self.lex_comment),
        ("\\", self.lex_backslash),
        ("([{", self.lex_open_bracket),
        (")]}", self.lex_close_bracket),
        ("-+*/<>%&|^~=!,@" + extra_misc, self.lex_misc),
    ]:
        for c in seq:
            self.map[c] = method
    if pyversion[0] == 2:
        self.keywords = keywords_common | keywords2
        # Decimal/hex/octal/binary literal or integer complex literal
        self.number_exp1 = re.compile("(0[xXoObB][0-9a-fA-F]+|[0-9]+)[lL]?")

    if pyversion[0] == 3:
        self.keywords = keywords_common | keywords3
        self.number_exp1 = re.compile("0[xXoObB][0-9a-fA-F]+|[0-9]+")