def format_exception_only(etype, value):
<EOL>if (isinstance(etype, BaseException) or<EOL>isinstance(etype, types.InstanceType) or<EOL>etype is None or type(etype) is str):<EOL><INDENT>return [_format_final_exc_line(etype, value)]<EOL><DEDENT>stype = etype.__name__<EOL>if not issubclass(etype, SyntaxError):<EOL><INDENT>return [_format_final_exc_line(stype, value)]<EOL><DEDENT>lines = []<EOL>try:<EOL><INDENT>msg, (filename, lineno, offset, badline) = value.args<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>filename = filename or "<STR_LIT>"<EOL>lines.append('<STR_LIT>' % (filename, lineno))<EOL>if badline is not None:<EOL><INDENT>lines.append('<STR_LIT>' % badline.strip())<EOL>if offset is not None:<EOL><INDENT>caretspace = badline.rstrip('<STR_LIT:\n>')<EOL>offset = min(len(caretspace), offset) - <NUM_LIT:1><EOL>caretspace = caretspace[:offset].lstrip()<EOL>caretspace = ((c.isspace() and c or '<STR_LIT:U+0020>') for c in caretspace)<EOL>lines.append('<STR_LIT>' % '<STR_LIT>'.join(caretspace))<EOL><DEDENT><DEDENT>value = msg<EOL><DEDENT>lines.append(_format_final_exc_line(stype, value))<EOL>return lines<EOL>
Format the exception part of a traceback.

    The arguments are the exception type and value such as given by
    sys.last_type and sys.last_value. The return value is a list of
    strings, each ending in a newline.

    Normally, the list contains a single string; however, for
    SyntaxError exceptions, it contains several lines that (when
    printed) display detailed information about where the syntax
    error occurred.

    The message indicating which exception occurred is always the last
    string in the list.