]> granicus.if.org Git - python/commitdiff
Corrected version of 1.170
authorRaymond Hettinger <python@rcn.com>
Sat, 10 Sep 2005 18:17:54 +0000 (18:17 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 10 Sep 2005 18:17:54 +0000 (18:17 +0000)
Lib/urllib.py

index a49b5865920b65224a073bf3ed2f7bbf7320c88c..bc16be0162aa922737f07d381f830f51c9bd6ced 100644 (file)
@@ -1110,12 +1110,9 @@ def quote(s, safe = '/'):
 def quote_plus(s, safe = ''):
     """Quote the query fragment of a URL; replacing ' ' with '+'"""
     if ' ' in s:
-        l = s.split(' ')
-        for i in range(len(l)):
-            l[i] = quote(l[i], safe)
-        return '+'.join(l)
-    else:
-        return quote(s, safe)
+        s = quote(s, safe + ' ')
+        return s.replace(' ', '+')
+    return quote(s, safe)
 
 def urlencode(query,doseq=0):
     """Encode a sequence of two-element tuples or dictionary into a URL query string.