Comment 4 for bug 488519

Revision history for this message
Eric Moritz (ericmoritz) wrote :

The problem is that the top variable is a unicode object and the values that are returned by _listdir() are regular strings. When sorted is ran over the values, it tries to compare the strings and unicode objects which triggers Python's automatic string decoding mechanism. This using the 'ascii' encoding by default.

A solution would be to map safe_unicode() to each filename returned by _listdir() and raise a more useful error. Something along the lines of "filename "x" is not encoded as utf8".