[Python-checkins] python/dist/src/Lib urllib.py,1.169,1.170
rhettinger@users.sourceforge.net
rhettinger at users.sourceforge.net
Sat Sep 10 04:27:44 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3622
Modified Files:
urllib.py
Log Message:
Simplify and speed-up quote_plus().
Index: urllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -d -r1.169 -r1.170
--- urllib.py 9 Sep 2005 22:27:13 -0000 1.169
+++ urllib.py 10 Sep 2005 02:27:41 -0000 1.170
@@ -1115,12 +1115,9 @@
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.
More information about the Python-checkins
mailing list