[Python-checkins] r59764 - in python/branches/release25-maint: Lib/urlparse.py Misc/NEWS

guido.van.rossum python-checkins at python.org
Sun Jan 6 03:40:07 CET 2008


Author: guido.van.rossum
Date: Sun Jan  6 03:40:07 2008
New Revision: 59764

Modified:
   python/branches/release25-maint/Lib/urlparse.py
   python/branches/release25-maint/Misc/NEWS
Log:
Forgot to backport the rest of #1637.


Modified: python/branches/release25-maint/Lib/urlparse.py
==============================================================================
--- python/branches/release25-maint/Lib/urlparse.py	(original)
+++ python/branches/release25-maint/Lib/urlparse.py	Sun Jan  6 03:40:07 2008
@@ -169,13 +169,12 @@
     return url[:i], url[i+1:]
 
 def _splitnetloc(url, start=0):
-    for c in '/?#': # the order is important!
-        delim = url.find(c, start)
-        if delim >= 0:
-            break
-    else:
-        delim = len(url)
-    return url[start:delim], url[delim:]
+    delim = len(url)   # position of end of domain part of url, default is end
+    for c in '/?#':    # look for delimiters; the order is NOT important
+        wdelim = url.find(c, start)        # find first of this delim
+        if wdelim >= 0:                    # if found
+            delim = min(delim, wdelim)     # use earliest delim position
+    return url[start:delim], url[delim:]   # return (domain, rest)
 
 def urlsplit(url, scheme='', allow_fragments=True):
     """Parse a URL into 5 components:

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Sun Jan  6 03:40:07 2008
@@ -53,6 +53,8 @@
 Library
 -------
 
+- Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
+
 - Issue #1735: TarFile.extractall() now correctly sets directory permissions
   and times.
 


More information about the Python-checkins mailing list