gurudesh/pytracebugs huggingface dataset:
# Buggy code
def _windows_bash_command(env=None):
    """Determines the command for Bash on windows."""
    wbc = "bash"
    path = None if env is None else env.get("PATH", None)
    bash_on_path = shutil.which("bash", path=path)
    if bash_on_path:
        # Check if Bash is from the "Windows Subsystem for Linux" (WSL)
        # which can't be used by xonsh foreign-shell/completer
        out = subprocess.check_output(
            [bash_on_path, "--version"], stderr=subprocess.PIPE, universal_newlines=True
        )
        if "pc-linux-gnu" in out.splitlines()[0]:
            gfwp = _git_for_windows_path()
            if gfwp:
                bashcmd = os.path.join(gfwp, "bin\\bash.exe")
                if os.path.isfile(bashcmd):
                    wbc = bashcmd
        else:
            wbc = bash_on_path
    return wbc


# Traceback (IndexError)
$ python Exception in thread Thread-81:
Traceback (most recent call last):
File "C:\Python35-32\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "C:\Python35-32\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "C:\Python35-32\lib\site-packages\prompt_toolkit\interface.py", line 835, in run
completions = list(buffer.completer.get_completions(document, complete_event))
File "C:\Python35-32\lib\site-packages\xonsh\ptk\completer.py", line 49, in get_completions
self.ctx)
File "C:\Python35-32\lib\site-packages\xonsh\__amalgam__.py", line 124, in complete
out = func(prefix, line, begidx, endidx, ctx)
File "C:\Python35-32\lib\site-packages\xonsh\completers\__amalgam__.py", line 1442, in complete_from_bash
command = xp.bash_command()
File "C:\Python35-32\lib\site-packages\xonsh\__amalgam__.py", line 1664, in bash_command
bc = windows_bash_command()
File "C:\Python35-32\lib\site-packages\xonsh\__amalgam__.py", line 1629, in windows_bash_command
bash_works = 'pc-linux-gnu' not in out.splitlines()[0]
IndexError: list index out of range

# Fixed code
def _windows_bash_command(env=None):
    """Determines the command for Bash on windows."""
    wbc = "bash"
    path = None if env is None else env.get("PATH", None)
    bash_on_path = shutil.which("bash", path=path)
    if bash_on_path:
        try:
            out = subprocess.check_output(
                [bash_on_path, "--version"],
                stderr=subprocess.PIPE,
                universal_newlines=True,
            )
        except subprocess.CalledProcessError:
            bash_works = False
        else:
            # Check if Bash is from the "Windows Subsystem for Linux" (WSL)
            # which can't be used by xonsh foreign-shell/completer
            bash_works = out and "pc-linux-gnu" not in out.splitlines()[0]

        if bash_works:
            wbc = bash_on_path
        else:
            gfwp = _git_for_windows_path()
            if gfwp:
                bashcmd = os.path.join(gfwp, "bin\\bash.exe")
                if os.path.isfile(bashcmd):
                    wbc = bashcmd
    return wbc
# Buggy code
def write(self, s):
    """Writes data to the original std stream and the in-memory object."""
    std_s = s
    if self.prestd:
        std_s = self.prestd + std_s
    if self.poststd:
        std_s += self.poststd
    self.std.write(std_s)
    self.mem.write(s)


# Traceback (ChildProcessError)
$ tail -f /tmp/goixy.log &amp;
[1]+ running: tail -f /tmp/some.log &amp; &amp; (30817)

$ fg
[1]+ running: tail -f /tmp/some.log &amp; (30817)
(**Here fg seems brought something into foreground, but stuck, let's ^C it**)

^C
$ Exception in thread Thread-16:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/proc.py",n
r = self.f(self.args, sp_stdin, sp_stdout, sp_stderr, spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/proc.py",o
return f(args, stdin)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/jobs.py",g
wait_for_active_job()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/jobs.py",b
_, wcode = os.waitpid(obj.pid, os.WUNTRACED)
ChildProcessError: [Errno 10] No child processes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _r
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/proc.py",n
print_exception()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/tools.py"n
traceback.print_exc()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/traceback.py", line 159, in pc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/traceback.py", line 101, in pn
print(line, file=file, end="")
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xonsh/base_shele
self.std.write(std_s)
AttributeError: 'NoneType' object has no attribute 'write'

# Fixed code
def write(self, s):
    """Writes data to the original std stream and the in-memory object."""
    self.mem.write(s)
    if self.std is None:
        return
    std_s = s
    if self.prestd:
        std_s = self.prestd + std_s
    if self.poststd:
        std_s += self.poststd
    self.std.write(std_s)
# Buggy code
def _fix_cwd(self):
    """Check if the cwd changed out from under us."""
    env = builtins.__xonsh_env__
    cwd = os.getcwd()
    if "PWD" not in env:
        # $PWD is missing from env, recreate it
        env["PWD"] = cwd
    elif os.path.realpath(cwd) != os.path.realpath(env["PWD"]):
        # The working directory has changed without updating $PWD, fix this
        old = env["PWD"]
        env["PWD"] = cwd
        env["OLDPWD"] = old
        events.on_chdir.fire(olddir=old, newdir=cwd)


# Traceback (FileNotFoundError)
🐚 ls
Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 221, in main
shell.shell.cmdloop()
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 119, in cmdloop
self.default(line)
File "/usr/lib/python3.5/site-packages/xonsh/base_shell.py", line 183, in default
builtins.__xonsh_env__['PWD'] = os.getcwd()        # track any change in working directory
FileNotFoundError: [Errno 2] No such file or directory

# Fixed code
def _fix_cwd(self):
    """Check if the cwd changed out from under us."""
    env = builtins.__xonsh_env__
    try:
        cwd = os.getcwd()
    except (FileNotFoundError, OSError):
        cwd = None
    if cwd is None:
        # directory has been deleted out from under us, most likely
        pwd = env.get("PWD", None)
        if pwd is None:
            # we have no idea where we are
            env["PWD"] = "<invalid directory>"
        elif os.path.isdir(pwd):
            # unclear why os.getcwd() failed. do nothing.
            pass
        else:
            # OK PWD is really gone.
            msg = "{UNDERLINE_INTENSE_WHITE}{BACKGROUND_INTENSE_BLACK}"
            msg += "xonsh: working directory does not exist: " + pwd
            msg += "{NO_COLOR}"
            self.print_color(msg, file=sys.stderr)
    elif "PWD" not in env:
        # $PWD is missing from env, recreate it
        env["PWD"] = cwd
    elif os.path.realpath(cwd) != os.path.realpath(env["PWD"]):
        # The working directory has changed without updating $PWD, fix this
        old = env["PWD"]
        env["PWD"] = cwd
        env["OLDPWD"] = old
        events.on_chdir.fire(olddir=old, newdir=cwd)
# Buggy code
def _get_hg_root(q):
    _curpwd = os.getcwd()
    while True:
        if any([b.name == ".hg" for b in os.scandir(_curpwd)]):
            q.put(_curpwd)
            break
        else:
            _oldpwd = _curpwd
            _curpwd = os.path.split(_curpwd)[0]
            if _oldpwd == _curpwd:
                return False


# Traceback (FileNotFoundError)
🐚 ls
Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 221, in main
shell.shell.cmdloop()
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 119, in cmdloop
self.default(line)
File "/usr/lib/python3.5/site-packages/xonsh/base_shell.py", line 183, in default
builtins.__xonsh_env__['PWD'] = os.getcwd()        # track any change in working directory
FileNotFoundError: [Errno 2] No such file or directory

# Fixed code
def _get_hg_root(q):
    _curpwd = builtins.__xonsh_env__["PWD"]
    while True:
        if not os.path.isdir(_curpwd):
            return False
        if any([b.name == ".hg" for b in os.scandir(_curpwd)]):
            q.put(_curpwd)
            break
        else:
            _oldpwd = _curpwd
            _curpwd = os.path.split(_curpwd)[0]
            if _oldpwd == _curpwd:
                return False
# Buggy code
def _command_is_valid(cmd):
    cmd_abspath = os.path.abspath(os.path.expanduser(cmd))
    return cmd in builtins.__xonsh_commands_cache__ or (
        os.path.isfile(cmd_abspath) and os.access(cmd_abspath, os.X_OK)
    )


# Traceback (FileNotFoundError)
🐚 ls
Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 221, in main
shell.shell.cmdloop()
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 119, in cmdloop
self.default(line)
File "/usr/lib/python3.5/site-packages/xonsh/base_shell.py", line 183, in default
builtins.__xonsh_env__['PWD'] = os.getcwd()        # track any change in working directory
FileNotFoundError: [Errno 2] No such file or directory

# Fixed code
def _command_is_valid(cmd):
    try:
        cmd_abspath = os.path.abspath(os.path.expanduser(cmd))
    except (FileNotFoundError, OSError):
        return False
    return cmd in builtins.__xonsh_commands_cache__ or (
        os.path.isfile(cmd_abspath) and os.access(cmd_abspath, os.X_OK)
    )
# Buggy code
def _command_is_autocd(cmd):
    if not builtins.__xonsh_env__.get("AUTO_CD", False):
        return False
    cmd_abspath = os.path.abspath(os.path.expanduser(cmd))
    return os.path.isdir(cmd_abspath)


# Traceback (FileNotFoundError)
🐚 ls
Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 221, in main
shell.shell.cmdloop()
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 119, in cmdloop
self.default(line)
File "/usr/lib/python3.5/site-packages/xonsh/base_shell.py", line 183, in default
builtins.__xonsh_env__['PWD'] = os.getcwd()        # track any change in working directory
FileNotFoundError: [Errno 2] No such file or directory

# Fixed code
def _command_is_autocd(cmd):
    if not builtins.__xonsh_env__.get("AUTO_CD", False):
        return False
    try:
        cmd_abspath = os.path.abspath(os.path.expanduser(cmd))
    except (FileNotFoundError, OSError):
        return False
    return os.path.isdir(cmd_abspath)
# Buggy code
def subproc_arg_callback(_, match):
    """Check if match contains valid path"""
    text = match.group()
    yield (
        match.start(),
        Name.Constant if os.path.exists(os.path.expanduser(text)) else Text,
        text,
    )


# Traceback (FileNotFoundError)
🐚 ls
Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 221, in main
shell.shell.cmdloop()
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 119, in cmdloop
self.default(line)
File "/usr/lib/python3.5/site-packages/xonsh/base_shell.py", line 183, in default
builtins.__xonsh_env__['PWD'] = os.getcwd()        # track any change in working directory
FileNotFoundError: [Errno 2] No such file or directory

# Fixed code
def subproc_arg_callback(_, match):
    """Check if match contains valid path"""
    text = match.group()
    try:
        ispath = os.path.exists(os.path.expanduser(text))
    except (FileNotFoundError, OSError):
        ispath = False
    yield (match.start(), Name.Constant if ispath else Text, text)
# Buggy code
def p_del_stmt(self, p):
    """del_stmt : del_tok exprlist"""
    p1 = p[1]
    p2 = p[2]
    for targ in p2:
        targ.ctx = ast.Del()
    p0 = ast.Delete(targets=p2, lineno=p1.lineno, col_offset=p1.lexpos)
    p[0] = p0


# Traceback (ValueError)
scopatz@artemis ~/xonsh amal $ x, y = 1, 2
scopatz@artemis ~/xonsh amal $ del (x, y)
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "/home/scopatz/.local/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 101, in push
locs=None)
File "/home/scopatz/.local/lib/python3.5/site-packages/xonsh/execer.py", line 108, in compile
code = compile(tree, filename, mode)
ValueError: expression must have Del context but has Load instead

# Fixed code
def p_del_stmt(self, p):
    """del_stmt : del_tok exprlist"""
    p1 = p[1]
    p2 = p[2]
    for targ in p2:
        del_ctx(targ)
    p0 = ast.Delete(targets=p2, ctx=ast.Del(), lineno=p1.lineno, col_offset=p1.lexpos)
    p[0] = p0
# Buggy code
def get_logical_line(lines, idx):
    """Returns a single logical line (i.e. one without line continuations)
    from a list of lines.  This line should begin at index idx. This also
    returns the number of physical lines the logical line spans. The lines
    should not contain newlines
    """
    n = 1
    nlines = len(lines)
    line = lines[idx]
    while line.endswith("\\") and idx < nlines:
        n += 1
        idx += 1
        line = line[:-1] + lines[idx]
    return line, n


# 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 get_logical_line(lines, idx):
    """Returns a single logical line (i.e. one without line continuations)
    from a list of lines.  This line should begin at index idx. This also
    returns the number of physical lines the logical line spans. The lines
    should not contain newlines
    """
    n = 1
    nlines = len(lines)
    line = lines[idx]
    while line.endswith(str(LINE_CONTINUATION)) and idx < nlines:
        n += 1
        idx += 1
        line = line[:-1] + lines[idx]
    return line, n
# Buggy code
def rl_on_new_line():
    """Grabs one of a few possible redisplay functions in readline."""
    names = ["rl_on_new_line", "rl_forced_update_display", "rl_redisplay"]
    for name in names:
        func = getattr(RL_LIB, name, None)
        if func is not None:
            break
    return func


# Traceback (TypeError)
Readline internal error
Traceback (most recent call last):
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
res = ensure_str(readline_hook(prompt))
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
self._readline_from_keyboard()
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
if self._readline_from_keyboard_poll():
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
result = self.mode.process_keyevent(event.keyinfo)
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
r = self.process_keyevent_queue[-1](keyinfo)
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
r = dispatch_func(keyinfo)
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
completions = self._get_completions()
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
r = self.completer(ensure_unicode(text), i)
File "C:\Users\mel\Anaconda3\lib\cmd.py", line 275, in complete
self.completion_matches = compfunc(text, line, begidx, endidx)
File "C:\Users\mel\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 18735, in completedefault
show_completions = self._querycompletions(completions, endidx - begidx)
File "C:\Users\mel\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 18695, in _querycompletions
rl_on_new_line()
TypeError: 'NoneType' object is not callable

# Fixed code
def rl_on_new_line():
    """Grabs one of a few possible redisplay functions in readline."""
    names = ["rl_on_new_line", "rl_forced_update_display", "rl_redisplay"]
    for name in names:
        func = getattr(RL_LIB, name, None)
        if func is not None:
            break
    else:

        def print_for_newline():
            print()

        func = print_for_newline
    return func
# Buggy code
def give_terminal_to(pgid):
    oldmask = signal.pthread_sigmask(signal.SIG_BLOCK, _block_when_giving)
    os.tcsetpgrp(sys.stderr.fileno(), pgid)
    signal.pthread_sigmask(signal.SIG_SETMASK, oldmask)
    return True


# Traceback (OSError)
$ timeit ls
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 12437, in run
r = self.f(self.args, sp_stdin, sp_stdout, sp_stderr, spec)
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 12266, in proxy_two
return f(args, stdin)
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 13794, in timeit_alias
time_number = timer.timeit(number)
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 13747, in timeit
timing = self.inner(it, self.timer)
File "<xonsh-timeit>", line 6, in inner
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 18340, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 18281, in run_subproc
command = HiddenCommandPipeline(specs)
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 12859, in __init__
if update_fg_process_group(pipeline_group, background):
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 12795, in update_fg_process_group
return give_terminal_to(pipeline_group)
File "/usr/local/lib/python3.5/dist-packages/xonsh/__amalgam__.py", line 8901, in give_terminal_to
os.tcsetpgrp(sys.stderr.fileno(), pgid)
OSError: [Errno 25] Inappropriate ioctl for device

# Fixed code
def give_terminal_to(pgid):
    oldmask = signal.pthread_sigmask(signal.SIG_BLOCK, _block_when_giving)
    os.tcsetpgrp(FD_STDERR, pgid)
    signal.pthread_sigmask(signal.SIG_SETMASK, oldmask)
    return True
# Buggy code
def run(self, *, pipeline_group=None):
    """Launches the subprocess and returns the object."""
    kwargs = {n: getattr(self, n) for n in self.kwnames}
    self.prep_env(kwargs)
    self.prep_preexec_fn(kwargs, pipeline_group=pipeline_group)
    if callable(self.alias):
        p = self.cls(self.alias, self.cmd, **kwargs)
    else:
        p = self._run_binary(kwargs)
    p.spec = self
    p.last_in_pipeline = self.last_in_pipeline
    p.captured_stdout = self.captured_stdout
    p.captured_stderr = self.captured_stderr
    return p


# Traceback (ProcessLookupError)
ls | more
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 17380, in default
run_compiled_code(code, self.ctx, None, 'single')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 1964, in run_compiled_code
func(code, glb, loc)
File "<xonsh-code>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16159, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16127, in run_subproc
command.end()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11116, in end
for _ in self.tee_stdout():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11041, in tee_stdout
for line in self.iterraw():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 10940, in iterraw
wait_for_active_job()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3694, in wait_for_active_job
_continue(active_task)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3607, in _continue
_send_signal(job, signal.SIGCONT)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3542, in _send_signal
os.kill(pid, signal)
ProcessLookupError: [Errno 3] No such process

# Fixed code
def run(self, *, pipeline_group=None):
    """Launches the subprocess and returns the object."""
    kwargs = {n: getattr(self, n) for n in self.kwnames}
    self.prep_env(kwargs)
    self.prep_preexec_fn(kwargs, pipeline_group=pipeline_group)
    if callable(self.alias):
        if "preexec_fn" in kwargs:
            kwargs.pop("preexec_fn")
        p = self.cls(self.alias, self.cmd, **kwargs)
    else:
        p = self._run_binary(kwargs)
    p.spec = self
    p.last_in_pipeline = self.last_in_pipeline
    p.captured_stdout = self.captured_stdout
    p.captured_stderr = self.captured_stderr
    return p
# Buggy code
def prep_preexec_fn(self, kwargs, pipeline_group=None):
    """Prepares the 'preexec_fn' keyword argument"""
    if not (ON_POSIX and self.cls is subprocess.Popen):
        return
    if not builtins.__xonsh_env__.get("XONSH_INTERACTIVE"):
        return
    if pipeline_group is None:
        xonsh_preexec_fn = no_pg_xonsh_preexec_fn
    else:

        def xonsh_preexec_fn():
            """Preexec function bound to a pipeline group."""
            os.setpgid(0, pipeline_group)
            signal.signal(signal.SIGTSTP, default_signal_pauser)

    kwargs["preexec_fn"] = xonsh_preexec_fn


# Traceback (ProcessLookupError)
ls | more
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 17380, in default
run_compiled_code(code, self.ctx, None, 'single')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 1964, in run_compiled_code
func(code, glb, loc)
File "<xonsh-code>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16159, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16127, in run_subproc
command.end()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11116, in end
for _ in self.tee_stdout():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11041, in tee_stdout
for line in self.iterraw():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 10940, in iterraw
wait_for_active_job()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3694, in wait_for_active_job
_continue(active_task)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3607, in _continue
_send_signal(job, signal.SIGCONT)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3542, in _send_signal
os.kill(pid, signal)
ProcessLookupError: [Errno 3] No such process

# Fixed code
def prep_preexec_fn(self, kwargs, pipeline_group=None):
    """Prepares the 'preexec_fn' keyword argument"""
    if not ON_POSIX:
        return
    if not builtins.__xonsh_env__.get("XONSH_INTERACTIVE"):
        return
    if pipeline_group is None:
        xonsh_preexec_fn = no_pg_xonsh_preexec_fn
    else:

        def xonsh_preexec_fn():
            """Preexec function bound to a pipeline group."""
            os.setpgid(0, pipeline_group)
            signal.signal(signal.SIGTSTP, default_signal_pauser)

    kwargs["preexec_fn"] = xonsh_preexec_fn
# Buggy code
def add_job(info):
    """Add a new job to the jobs dictionary."""
    num = get_next_job_number()
    info["started"] = time.time()
    info["status"] = "running"
    _set_pgrp(info)
    tasks.appendleft(num)
    builtins.__xonsh_all_jobs__[num] = info
    if info["bg"]:
        print_one_job(num)


# Traceback (ProcessLookupError)
ls | more
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 17380, in default
run_compiled_code(code, self.ctx, None, 'single')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 1964, in run_compiled_code
func(code, glb, loc)
File "<xonsh-code>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16159, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16127, in run_subproc
command.end()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11116, in end
for _ in self.tee_stdout():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11041, in tee_stdout
for line in self.iterraw():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 10940, in iterraw
wait_for_active_job()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3694, in wait_for_active_job
_continue(active_task)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3607, in _continue
_send_signal(job, signal.SIGCONT)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3542, in _send_signal
os.kill(pid, signal)
ProcessLookupError: [Errno 3] No such process

# Fixed code
def add_job(info):
    """Add a new job to the jobs dictionary."""
    num = get_next_job_number()
    info["started"] = time.time()
    info["status"] = "running"
    tasks.appendleft(num)
    builtins.__xonsh_all_jobs__[num] = info
    if info["bg"]:
        print_one_job(num)
# Buggy code
def end(self, tee_output=True):
    """Waits for the command to complete and then runs any closing and
    cleanup procedures that need to be run.
    """
    if self.ended:
        return
    if tee_output:
        for _ in self.tee_stdout():
            pass
    self._endtime()
    # since we are driven by getting output, input may not be available
    # until the command has completed.
    self._set_input()
    self._close_prev_procs()
    self._close_proc()
    self._check_signal()
    self._apply_to_history()
    self.ended = True
    self._raise_subproc_error()


# Traceback (ProcessLookupError)
ls | more
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 17380, in default
run_compiled_code(code, self.ctx, None, 'single')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 1964, in run_compiled_code
func(code, glb, loc)
File "<xonsh-code>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16159, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 16127, in run_subproc
command.end()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11116, in end
for _ in self.tee_stdout():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 11041, in tee_stdout
for line in self.iterraw():
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 10940, in iterraw
wait_for_active_job()
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3694, in wait_for_active_job
_continue(active_task)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3607, in _continue
_send_signal(job, signal.SIGCONT)
File "/usr/local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 3542, in _send_signal
os.kill(pid, signal)
ProcessLookupError: [Errno 3] No such process

# Fixed code
def end(self, tee_output=True):
    """
    End the pipeline, return the controlling terminal if needed.

    Main things done in self._end().
    """
    if self.ended:
        return
    self._end(tee_output=tee_output)
    self._return_terminal()
# Buggy code
def flush(self):
    """Flushes the file descriptor for the current thread."""
    return self.handle.flush()


# Traceback (OSError)
$ def _f(args, stdin=None):
..     print('hello')
..
$ aliases['f'] = _f
$ f > /dev/null
Exception in thread Thread-66:
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 10062, in run
sp_stdout = io.TextIOWrapper(io.open(self.c2pwrite, 'wb', -1),
OSError: [Errno 9] Bad file descriptor

# Fixed code
def flush(self):
    """Flushes the file descriptor for the current thread."""
    return safe_flush(self.handle)
# Buggy code
def get_completions(self, document, complete_event):
    """Returns a generator for list of completions."""

    #  Only generate completions when the user hits tab.
    if complete_event.completion_requested:
        line = document.current_line.lstrip()
        endidx = document.cursor_position_col
        begidx = line[:endidx].rfind(" ") + 1 if line[:endidx].rfind(" ") >= 0 else 0
        prefix = line[begidx:endidx]
        completions, l = self.completer.complete(prefix, line, begidx, endidx, self.ctx)
        if len(completions) <= 1:
            pass
        elif len(os.path.commonprefix(completions)) <= len(prefix):
            self.reserve_space()
        for comp in completions:
            yield Completion(comp, -l)


# Traceback (AttributeError)
cryzed@arch ~ $ xonsh update-aur-gits.xsh
Traceback (most recent call last):
File "/usr/bin/xonsh", line 9, in <module>
load_entry_point('xonsh==0.3.2', 'console_scripts', 'xonsh')()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 228, in main
args = premain(argv)
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 215, in premain
shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
File "/usr/lib/python3.5/site-packages/xonsh/shell.py", line 72, in __init__
ctx=self.ctx, **kwargs)
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 33, in __init__
self.pt_completer = PromptToolkitCompleter(self.completer, self.ctx)
AttributeError: 'PromptToolkitShell' object has no attribute 'completer'

# Fixed code
def get_completions(self, document, complete_event):
    """Returns a generator for list of completions."""

    #  Only generate completions when the user hits tab.
    if complete_event.completion_requested:
        if self.completer is None:
            yield from []
        else:
            line = document.current_line.lstrip()
            endidx = document.cursor_position_col
            begidx = (
                line[:endidx].rfind(" ") + 1 if line[:endidx].rfind(" ") >= 0 else 0
            )
            prefix = line[begidx:endidx]
            completions, l = self.completer.complete(
                prefix, line, begidx, endidx, self.ctx
            )
            if len(completions) <= 1:
                pass
            elif len(os.path.commonprefix(completions)) <= len(prefix):
                self.reserve_space()
            for comp in completions:
                yield Completion(comp, -l)
# Buggy code
def completedefault(self, text, line, begidx, endidx):
    """Implements tab-completion for text."""
    rl_completion_suppress_append()  # this needs to be called each time
    mline = line.partition(" ")[2]
    offs = len(mline) - len(text)
    x = [
        (i[offs:] if " " in i[:-1] else i)
        for i in self.completer.complete(text, line, begidx, endidx, ctx=self.ctx)[0]
    ]
    return x


# Traceback (AttributeError)
cryzed@arch ~ $ xonsh update-aur-gits.xsh
Traceback (most recent call last):
File "/usr/bin/xonsh", line 9, in <module>
load_entry_point('xonsh==0.3.2', 'console_scripts', 'xonsh')()
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 228, in main
args = premain(argv)
File "/usr/lib/python3.5/site-packages/xonsh/main.py", line 215, in premain
shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
File "/usr/lib/python3.5/site-packages/xonsh/shell.py", line 72, in __init__
ctx=self.ctx, **kwargs)
File "/usr/lib/python3.5/site-packages/xonsh/ptk/shell.py", line 33, in __init__
self.pt_completer = PromptToolkitCompleter(self.completer, self.ctx)
AttributeError: 'PromptToolkitShell' object has no attribute 'completer'

# Fixed code
def completedefault(self, text, line, begidx, endidx):
    """Implements tab-completion for text."""
    rl_completion_suppress_append()  # this needs to be called each time
    mline = line.partition(" ")[2]
    offs = len(mline) - len(text)
    if self.completer is None:
        x = []
    else:
        x = [
            (i[offs:] if " " in i[:-1] else i)
            for i in self.completer.complete(text, line, begidx, endidx, ctx=self.ctx)[
                0
            ]
        ]
    return x
# Buggy code
def is_in_scope(self, node):
    """Determines whether or not the current node is in scope."""
    names = gather_names(node)
    if not names:
        return True
    inscope = False
    for ctx in reversed(self.contexts):
        names -= ctx
        if not names:
            inscope = True
            break
    return inscope


# Traceback (FileNotFoundError)
cryzed@arch ~ $ python test.py
8
cryzed@arch ~ $ xonsh test.py
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16319, in run_subproc
**subproc_kwargs)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'for'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 17534, in main
loc=None, mode='exec')
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 2041, in run_script_with_cache
run_compiled_code(ccode, glb, loc, mode)
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 1961, in run_compiled_code
func(code, glb, loc)
File "test.py", line 15, in <module>
print(len(get_all_paths(HOME_BIN)))
File "test.py", line 9, in get_all_paths
paths.extend(os.path.join(root, d) for d in dirs)
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16456, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16329, in run_subproc
raise XonshError(e)
xonsh.__amalgam__.XonshError: xonsh: subprocess mode: command not found: for
Did you mean one of the following?
pr:   Command (/usr/bin/pr)
EOF:  Alias
tr:   Command (/usr/bin/tr)
od:   Command (/usr/bin/od)
fg:   Alias

# Fixed code
def is_in_scope(self, node):
    """Determines whether or not the current node is in scope."""
    names, store = gather_load_store_names(node)
    names -= store
    if not names:
        return True
    inscope = False
    for ctx in reversed(self.contexts):
        names -= ctx
        if not names:
            inscope = True
            break
    return inscope
# Buggy code
def visit_For(self, node):
    """Handle visiting a for statement."""
    targ = node.target
    if isinstance(targ, (Tuple, List)):
        self.ctxupdate(leftmostname(elt) for elt in targ.elts)
    else:
        self.ctxadd(leftmostname(targ))
    self.generic_visit(node)
    return node


# Traceback (FileNotFoundError)
cryzed@arch ~ $ python test.py
8
cryzed@arch ~ $ xonsh test.py
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16319, in run_subproc
**subproc_kwargs)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'for'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/xonsh", line 3, in <module>
main()
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 17534, in main
loc=None, mode='exec')
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 2041, in run_script_with_cache
run_compiled_code(ccode, glb, loc, mode)
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 1961, in run_compiled_code
func(code, glb, loc)
File "test.py", line 15, in <module>
print(len(get_all_paths(HOME_BIN)))
File "test.py", line 9, in get_all_paths
paths.extend(os.path.join(root, d) for d in dirs)
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16456, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16329, in run_subproc
raise XonshError(e)
xonsh.__amalgam__.XonshError: xonsh: subprocess mode: command not found: for
Did you mean one of the following?
pr:   Command (/usr/bin/pr)
EOF:  Alias
tr:   Command (/usr/bin/tr)
od:   Command (/usr/bin/od)
fg:   Alias

# Fixed code
def visit_For(self, node):
    """Handle visiting a for statement."""
    targ = node.target
    self.ctxupdate(gather_names(targ))
    self.generic_visit(node)
    return node
# Buggy code
def _get_color_indexes(style_map):
    """Generates the color and windows color index for a style"""
    import prompt_toolkit

    table = prompt_toolkit.terminal.win32_output.ColorLookupTable()
    pt_style = prompt_toolkit.styles.style_from_dict(style_map)
    for token in style_map:
        attr = pt_style.token_to_attrs[token]
        if attr.color is not None:
            index = table.lookup_color(attr.color, attr.bgcolor)
            try:
                rgb = (
                    int(attr.color[0:2], 16),
                    int(attr.color[2:4], 16),
                    int(attr.color[4:6], 16),
                )
            except Exception:
                rgb = None
            yield token, index, rgb


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Python35-32\lib\runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python35-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python35-32\lib\site-packages\xonsh\main.py", line 265, in <module>
main()
File "C:\Python35-32\lib\site-packages\xonsh\main.py", line 222, in main
shell.shell.cmdloop()
File "C:\Python35-32\lib\site-packages\xonsh\ptk\shell.py", line 115, in cmdloop
line = self.singleline(auto_suggest=auto_suggest)
File "C:\Python35-32\lib\site-packages\xonsh\ptk\shell.py", line 60, in singleline
self.styler.style_name = env.get('XONSH_COLOR_STYLE')
File "C:\Python35-32\lib\site-packages\xonsh\base_shell.py", line 126, in styler
self._styler = XonshStyle(env.get('XONSH_COLOR_STYLE'))
File "C:\Python35-32\lib\site-packages\xonsh\pyghooks.py", line 309, in __init__
self.style_name = style_name
File "C:\Python35-32\lib\site-packages\xonsh\pyghooks.py", line 334, in style_name
self.enhance_colors_for_cmd_exe()
File "C:\Python35-32\lib\site-packages\xonsh\pyghooks.py", line 351, in enhance_colors_for_cmd_exe
self._smap.update(expand_gray_colors_for_cmd_exe(self._smap))
File "C:\Python35-32\lib\site-packages\xonsh\tools.py", line 1319, in expand_gray_colors_for_cmd_exe
for token, idx, rgb in _get_color_indexes(style_map):
File "C:\Python35-32\lib\site-packages\xonsh\tools.py", line 1272, in _get_color_indexes
index = table.lookup_color(attr.color, attr.bgcolor)
AttributeError: 'ColorLookupTable' object has no attribute 'lookup_color'

# Fixed code
def _get_color_indexes(style_map):
    """Generates the color and windows color index for a style"""
    import prompt_toolkit

    table = prompt_toolkit.terminal.win32_output.ColorLookupTable()
    pt_style = prompt_toolkit.styles.style_from_dict(style_map)
    for token in style_map:
        attr = pt_style.token_to_attrs[token]
        if attr.color is not None:
            try:
                index = table.lookup_color(attr.color, attr.bgcolor)
            except AttributeError:
                index = table.lookup_fg_color(attr.color)
            try:
                rgb = (
                    int(attr.color[0:2], 16),
                    int(attr.color[2:4], 16),
                    int(attr.color[4:6], 16),
                )
            except Exception:
                rgb = None
            yield token, index, rgb
# Buggy code
def _send_signal(job, signal):
    os.killpg(job["pgrp"], signal)


# Traceback (TypeError)
└─> % history zsh | grep nvidia
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
204: nvidia-smi -l
Traceback (most recent call last):
File "/home/home51/lunz8748/usr/xonsh/xonsh/base_shell.py", line 167, in default
run_compiled_code(code, self.ctx, None, 'single')
File "/home/home51/lunz8748/usr/xonsh/xonsh/codecache.py", line 66, in run_compiled_code
func(code, glb, loc)
File "<xonsh-code>", line 1, in <module>
File "/home/home51/lunz8748/usr/xonsh/xonsh/built_ins.py", line 635, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/home/home51/lunz8748/usr/xonsh/xonsh/built_ins.py", line 517, in run_subproc
'bg': background
File "/home/home51/lunz8748/usr/xonsh/xonsh/jobs.py", line 260, in add_job
_set_pgrp(info)
File "/home/home51/lunz8748/usr/xonsh/xonsh/jobs.py", line 103, in _set_pgrp
info['pgrp'] = os.getpgid(info['pids'][0])
TypeError: an integer is required (got type NoneType)

# Fixed code
def _send_signal(job, signal):
    pgrp = job["pgrp"]
    if pgrp is None:
        for pid in job["pids"]:
            try:
                os.kill(pid, signal)
            except:
                pass
    else:
        os.killpg(job["pgrp"], signal)
# Buggy code
def _set_pgrp(info):
    try:
        info["pgrp"] = os.getpgid(info["pids"][0])
    except ProcessLookupError:
        pass


# Traceback (TypeError)
└─> % history zsh | grep nvidia
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
204: nvidia-smi -l
Traceback (most recent call last):
File "/home/home51/lunz8748/usr/xonsh/xonsh/base_shell.py", line 167, in default
run_compiled_code(code, self.ctx, None, 'single')
File "/home/home51/lunz8748/usr/xonsh/xonsh/codecache.py", line 66, in run_compiled_code
func(code, glb, loc)
File "<xonsh-code>", line 1, in <module>
File "/home/home51/lunz8748/usr/xonsh/xonsh/built_ins.py", line 635, in subproc_captured_hiddenobject
return run_subproc(cmds, captured='hiddenobject')
File "/home/home51/lunz8748/usr/xonsh/xonsh/built_ins.py", line 517, in run_subproc
'bg': background
File "/home/home51/lunz8748/usr/xonsh/xonsh/jobs.py", line 260, in add_job
_set_pgrp(info)
File "/home/home51/lunz8748/usr/xonsh/xonsh/jobs.py", line 103, in _set_pgrp
info['pgrp'] = os.getpgid(info['pids'][0])
TypeError: an integer is required (got type NoneType)

# Fixed code
def _set_pgrp(info):
    pid = info["pids"][0]
    if pid is None:
        # occurs if first process is an alias
        info["pgrp"] = None
        return
    try:
        info["pgrp"] = os.getpgid(pid)
    except ProcessLookupError:
        info["pgrp"] = None