16
In my Django application, a user has uploaded a file with a unicode character in the name.
When I'm downloading files, I'm calling :
os.path.exists(media)
to test that the file is there. This, in turn, seems to call
st = os.stat(path)
Which then blows up with the error :
UnicodeEncodeError: 'ascii' codec can't encode character u'\xcf' in position 92: ordinal not in range(128)
What can I do about this? Is there an option to path.exists to handle it?
Update : Actually, all I had to do was encode the argument to exists, ie.
os.path.exists(media.encode('utf-8')
Thanks everyone who answered.