Project

General

Profile

« Previous | Next » 

Revision 2879

exc.py: str_(): Fixed bug where UnicodeEncodeError would be raised when msg contains non-ASCII chars, by wrapping e.args0 in strings.ustr()

View differences:

lib/exc.py
63 63
        # Avoid traceback exception-formatting functions because they escape
64 64
        # non-ASCII characters with \x, causing exception parsers to read an
65 65
        # incorrect, escaped value.
66
        msg = util.class_name(e)+': '+e.args[0]
66
        msg = util.class_name(e)+': '+strings.ustr(e.args[0])
67 67
    
68 68
    if first_line_only: msg = msg.partition('\n')[0]
69 69
    return msg.rstrip()
......
78 78
    if emph:
79 79
        first_line, nl, rest = msg.partition('\n')
80 80
        msg = term.error(first_line)+nl+rest
81
    sys.stderr.write(strings.to_unicode(msg))
81
    sys.stderr.write(msg)
82 82

  
83 83
class ExTracker:
84 84
    def __init__(self):

Also available in: Unified diff