diff options
author | Raymond Hettinger <python@rcn.com> | 2005-09-10 02:27:41 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-09-10 02:27:41 (GMT) |
commit | 957b1266492877d97a790a5698a9492512e5b8cd (patch) | |
tree | d88f20681d4e840bf77d291ba0c1650b392b1884 /Lib/urllib.py | |
parent | 199d2f79972431e1d47eaaea8cdb6cab78669d14 (diff) | |
download | cpython-957b1266492877d97a790a5698a9492512e5b8cd.zip cpython-957b1266492877d97a790a5698a9492512e5b8cd.tar.gz cpython-957b1266492877d97a790a5698a9492512e5b8cd.tar.bz2 |
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 b8ba454..2889b3d 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. |