diff options
author | Raymond Hettinger <python@rcn.com> | 2005-09-10 02:27:41 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-09-10 02:27:41 +0000 |
commit | f736e7401e36db8e0ca26a940647259b8d6fc5db (patch) | |
tree | 5409f824bacbbf3816f9b1342e347febf370ea08 /Lib/urllib.py | |
parent | 2e6f7555ad188e69f0dc9b148ea7b45bc5d70260 (diff) | |
download | cpython-f736e7401e36db8e0ca26a940647259b8d6fc5db.tar.gz |
Simplify and speed-up quote_plus().
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 9 |
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. |