title: urllib.quote() throws KeyError
body: <p>To encode the URI, I used <code>urllib.quote("schönefeld")</code> but when some non-ascii characters exists in string, it thorws</p>
  
  <pre><code>KeyError: u'\xe9'
  Code: return ''.join(map(quoter, s))
  </code></pre>
  
  <p>My input strings are <code>köln, brønshøj, schönefeld</code> etc.</p>
  
  <p>When I tried just printing statements in windows(Using python2.7, pyscripter IDE). But in linux it raises exception (I guess platform doesn't matter).</p>
  
  <p>This is what I am trying:</p>
  
  <pre><code>from commands import getstatusoutput
  queryParams = "schönefeld";
  cmdString = "http://baseurl" + quote(queryParams)
  print getstatusoutput(cmdString)
  </code></pre>
  
  <p><strong>Exploring the issue reason:</strong>
  in <code>urllib.quote()</code>, actually exception being throwin at <code>return ''.join(map(quoter, s))</code>.</p>
  
  <p>The code in urllib is: </p>
  
  <pre><code>def quote(s, safe='/'):
      if not s:
          if s is None:
              raise TypeError('None object cannot be quoted')
          return s
       cachekey = (safe, always_safe)
       try:
           (quoter, safe) = _safe_quoters[cachekey]
       except KeyError:
           safe_map = _safe_map.copy()
           safe_map.update([(c, c) for c in safe])
           quoter = safe_map.__getitem__
           safe = always_safe + safe
           _safe_quoters[cachekey] = (quoter, safe)
        if not s.rstrip(safe):
           return s
        return ''.join(map(quoter, s))
  </code></pre>
  
  <p>The reason for exception is in <code>''.join(map(quoter, s))</code>, for every element in s, quoter function will be called and finally the list will be joined by '' and returned.</p>
  
  <p>For non-ascii char <code>è</code>, the equivalent key will be <code>%E8</code> which presents in <code>_safe_map</code> variable. But when I am calling quote('è'), it searches for the key <code>\xe8</code>. So that the key does not exist and exception thrown.</p>
  
  <p>So, I just modifed <code>s = [el.upper().replace("\\X","%") for el in s]</code> before calling <code>''.join(map(quoter, s))</code> within try-except block. Now it works fine.</p>
  
  <p>But I am annoying what I have done is correct approach or it will create any other issue?
  And also I do have 200+ instances of linux which is very tough to deploy this fix in all instances.</p>