summaryrefslogtreecommitdiff
path: root/Lib/urllib.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-09-10 02:27:41 +0000
committerRaymond Hettinger <python@rcn.com>2005-09-10 02:27:41 +0000
commitf736e7401e36db8e0ca26a940647259b8d6fc5db (patch)
tree5409f824bacbbf3816f9b1342e347febf370ea08 /Lib/urllib.py
parent2e6f7555ad188e69f0dc9b148ea7b45bc5d70260 (diff)
downloadcpython-f736e7401e36db8e0ca26a940647259b8d6fc5db.tar.gz
Simplify and speed-up quote_plus().
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index b8ba454022..2889b3dbfb 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -1115,12 +1115,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 = s.replace(' ', '+')
+ safe += '+'
+ return quote(s, safe)
def urlencode(query,doseq=0):
"""Encode a sequence of two-element tuples or dictionary into a URL query string.