title: Strange `UnicodeEncodeError` using `os.path.exists`
body: <p>In a web-application (using Flask), I get the following error:</p>
  
  <pre><code>Unable to retrieve the thumbnail for u'/var/data/uploads/2012/03/22/12 Gerd\xb4s Banjo Trio 1024.jpg'
  Traceback (most recent call last):
   File "/var/www/beta/env/lib/python2.7/site-packages/dblib-1.0dev3-py2.7.egg/dblib/orm/file.py", line 169, in get_thumbnail
     if not exists(filename):
   File "/usr/lib/python2.7/genericpath.py", line 18, in exists
     os.stat(path)
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xb4' in position 52: ordinal not in range(128)
  </code></pre>
  
  <p>Note that I include the <code>repr()</code> of the file name in the logged error. This shows that the file name is passed as a Unicode instance. So much is correct...</p>
  
  <p>If I run the culprit using the python interpreter, it works as expected:</p>
  
  <pre><code>&gt;&gt;&gt; from os.path import exists
  &gt;&gt;&gt; exists(u'/var/data/uploads/2012/03/22/12 Gerd\xb4s Banjo Trio 1024.jpg')
  True
  </code></pre>
  
  <p>So obviously, while running in the Flask environment, Python thinks it should encode the file-name using the ASCII codec instead of UTF-8. I deployed the application using mod_wsgi behind the Apache httpd.</p>
  
  <p>I assume I have to tell either one of them to use UTF-8 somewhere? But where?</p>