title: Is there a unicode-ready substitute I can use for urllib.quote and urllib.unquote in Python 2.6.5?
body: <p>Python's <code>urllib.quote</code> and <code>urllib.unquote</code> do not handle Unicode correctly in Python 2.6.5. This is what happens:</p>
  
  <pre><code>In [5]: print urllib.unquote(urllib.quote(u'Cataño'))
  ---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  
  /home/kkinder/&lt;ipython console&gt; in &lt;module&gt;()
  
  /usr/lib/python2.6/urllib.pyc in quote(s, safe)
     1222             safe_map[c] = (c in safe) and c or ('%%%02X' % i)
     1223         _safemaps[cachekey] = safe_map
  -&gt; 1224     res = map(safe_map.__getitem__, s)
     1225     return ''.join(res)
     1226 
  
  KeyError: u'\xc3'
  </code></pre>
  
  <p>Encoding the value to UTF8 also does not work:</p>
  
  <pre><code>In [6]: print urllib.unquote(urllib.quote(u'Cataño'.encode('utf8')))
  CataÃ±o
  </code></pre>
  
  <p>It's recognized as a bug and <a href="http://hg.python.org/cpython/rev/1e21d94e05f4/" rel="noreferrer">there is a fix</a>, but not for my version of Python.</p>
  
  <p>What I'd like is something similar to urllib.quote/urllib.unquote, but handles unicode variables correctly, such that this code would work:</p>
  
  <pre><code>decode_url(encode_url(u'Cataño')) == u'Cataño'
  </code></pre>
  
  <p>Any recommendations?</p>