# Buggy code
def print_exception(msg=None):
    """Print exceptions with/without traceback."""
    env = getattr(builtins, "__xonsh_env__", os.environ)
    # flags indicating whether the traceback options have been manually set
    manually_set_trace = env.is_manually_set("XONSH_SHOW_TRACEBACK")
    manually_set_logfile = env.is_manually_set("XONSH_TRACEBACK_LOGFILE")
    if (not manually_set_trace) and (not manually_set_logfile):
        # Notify about the traceback output possibility if neither of
        # the two options have been manually set
        sys.stderr.write(
            "xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True\n"
        )
    # get env option for traceback and convert it if necessary
    show_trace = env.get("XONSH_SHOW_TRACEBACK", False)
    if not is_bool(show_trace):
        show_trace = to_bool(show_trace)
    # if the trace option has been set, print all traceback info to stderr
    if show_trace:
        # notify user about XONSH_TRACEBACK_LOGFILE if it has
        # not been set manually
        if not manually_set_logfile:
            sys.stderr.write(
                "xonsh: To log full traceback to a file set: "
                "$XONSH_TRACEBACK_LOGFILE = <filename>\n"
            )
        traceback.print_exc()

    # additionally, check if a file for traceback logging has been
    # specified and convert to a proper option if needed
    log_file = env.get("XONSH_TRACEBACK_LOGFILE", None)
    log_file = to_logfile_opt(log_file)
    if log_file:
        # if log_file <> '' or log_file <> None, append
        # traceback log there as well
        with open(os.path.abspath(log_file), "a") as f:
            traceback.print_exc(file=f)

    if not show_trace:
        # if traceback output is disabled, print the exception's
        # error message on stderr.
        display_error_message()
    if msg:
        msg = msg if msg.endswith("\n") else msg + "\n"
        sys.stderr.write(msg)


# Traceback (json.decoder.JSONDecodeError)
Traceback (most recent call last):
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 11997, in load_static_config
conf = json.load(f)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/json/__init__.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/christopher/mc/envs/xonsh/lib/python3.5/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 7 column 1 (char 53)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/christopher/mc/envs/xonsh/bin/xonsh", line 6, in <module>
sys.exit(xonsh.main.main())
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16394, in main
args = premain(argv)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16381, in premain
shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16125, in __init__
kwargs.get('cacheall', False))
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16167, in _init_environ
debug_level=debug)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 15811, in __init__
load_builtins(execer=self, config=config, login=login, ctx=xonsh_ctx)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 15651, in load_builtins
builtins.__xonsh_env__ = ENV = Env(default_env(config=config, login=login))
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 12084, in default_env
conf = load_static_config(ctx, config=config)
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 12003, in load_static_config
print_exception()
File "/home/christopher/mc/envs/xonsh/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 5559, in print_exception
manually_set_trace = env.is_manually_set('XONSH_SHOW_TRACEBACK')
AttributeError: '_Environ' object has no attribute 'is_manually_set'

# Fixed code
def print_exception(msg=None):
    """Print exceptions with/without traceback."""
    env = getattr(builtins, "__xonsh_env__", None)
    # flags indicating whether the traceback options have been manually set
    if env is None:
        env = os.environ
        manually_set_trace = "XONSH_SHOW_TRACEBACK" in env
        manually_set_logfile = "XONSH_TRACEBACK_LOGFILE" in env
    else:
        manually_set_trace = env.is_manually_set("XONSH_SHOW_TRACEBACK")
        manually_set_logfile = env.is_manually_set("XONSH_TRACEBACK_LOGFILE")
    if (not manually_set_trace) and (not manually_set_logfile):
        # Notify about the traceback output possibility if neither of
        # the two options have been manually set
        sys.stderr.write(
            "xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True\n"
        )
    # get env option for traceback and convert it if necessary
    show_trace = env.get("XONSH_SHOW_TRACEBACK", False)
    if not is_bool(show_trace):
        show_trace = to_bool(show_trace)
    # if the trace option has been set, print all traceback info to stderr
    if show_trace:
        # notify user about XONSH_TRACEBACK_LOGFILE if it has
        # not been set manually
        if not manually_set_logfile:
            sys.stderr.write(
                "xonsh: To log full traceback to a file set: "
                "$XONSH_TRACEBACK_LOGFILE = <filename>\n"
            )
        traceback.print_exc()
    # additionally, check if a file for traceback logging has been
    # specified and convert to a proper option if needed
    log_file = env.get("XONSH_TRACEBACK_LOGFILE", None)
    log_file = to_logfile_opt(log_file)
    if log_file:
        # if log_file <> '' or log_file <> None, append
        # traceback log there as well
        with open(os.path.abspath(log_file), "a") as f:
            traceback.print_exc(file=f)

    if not show_trace:
        # if traceback output is disabled, print the exception's
        # error message on stderr.
        display_error_message()
    if msg:
        msg = msg if msg.endswith("\n") else msg + "\n"
        sys.stderr.write(msg)