# Buggy code
def compile(self, src):
    """Compiles source code and returns the (possibly modified) source and
    a valid code object.
    """
    _cache = should_use_cache(self.execer, "single")
    if _cache:
        codefname = code_cache_name(src)
        cachefname = get_cache_filename(codefname, code=True)
        usecache, code = code_cache_check(cachefname)
        if usecache:
            self.reset_buffer()
            return src, code
    if src.endswith("\\\n"):
        self.need_more_lines = True
        return src, None
    try:
        code = self.execer.compile(src, mode="single", glbs=self.ctx, locs=None)
        if _cache:
            update_cache(code, cachefname)
        self.reset_buffer()
    except SyntaxError:
        partial_string_info = check_for_partial_string(src)
        in_partial_string = (
            partial_string_info[0] is not None and partial_string_info[1] is None
        )
        if (src == "\n" or src.endswith("\n\n")) and not in_partial_string:
            self.reset_buffer()
            print_exception()
            return src, None
        self.need_more_lines = True
        code = None
    except Exception:  # pylint: disable=broad-except
        self.reset_buffer()
        print_exception()
        code = None
    return src, code


# Traceback (SyntaxError)
rymg1@DEVPC ~ $ cd abc\
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\__amalgam__.py", line 19218, in _parse_ctx_free
debug_level=(self.debug_level > 2))
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\parsers\base.py", line 335, in parse
tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\ply\ply\yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\ply\ply\yacc.py", line 1199, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\ply\ply\yacc.py", line 193, in call_errorfunc
r = errorfunc(token)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\parsers\base.py", line 2694, in p_error
column=p.lexpos))
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\parsers\base.py", line 466, in _parse_error
raise err
File "<string>", line None
SyntaxError: <xonsh-code>:1:2: ('code: abc',)
cd abc\
^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\ptk\shell.py", line 137, in _push
locs=None)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\__amalgam__.py", line 19163, in compile
transform=transform)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\__amalgam__.py", line 19133, in parse
tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\__amalgam__.py", line 19236, in _parse_ctx_free
line, nlogical = get_logical_line(lines, idx)
File "C:\Program Files (x86)\Python35\lib\site-packages\xonsh\__amalgam__.py", line 5433, in get_logical_line
line = line[:-1] + lines[idx]
IndexError: list index out of range
rymg1@DEVPC ~ $

# Fixed code
def compile(self, src):
    """Compiles source code and returns the (possibly modified) source and
    a valid code object.
    """
    _cache = should_use_cache(self.execer, "single")
    if _cache:
        codefname = code_cache_name(src)
        cachefname = get_cache_filename(codefname, code=True)
        usecache, code = code_cache_check(cachefname)
        if usecache:
            self.reset_buffer()
            return src, code
    if src.endswith(str(LINE_CONTINUATION) + "\n"):
        self.need_more_lines = True
        return src, None
    try:
        code = self.execer.compile(src, mode="single", glbs=self.ctx, locs=None)
        if _cache:
            update_cache(code, cachefname)
        self.reset_buffer()
    except SyntaxError:
        partial_string_info = check_for_partial_string(src)
        in_partial_string = (
            partial_string_info[0] is not None and partial_string_info[1] is None
        )
        if (src == "\n" or src.endswith("\n\n")) and not in_partial_string:
            self.reset_buffer()
            print_exception()
            return src, None
        self.need_more_lines = True
        code = None
    except Exception:  # pylint: disable=broad-except
        self.reset_buffer()
        print_exception()
        code = None
    return src, code