]> granicus.if.org Git - python/commitdiff
Feeble attempt at making urlopen more robust -- don't call splituser()
authorGuido van Rossum <guido@python.org>
Mon, 27 Apr 1998 15:19:17 +0000 (15:19 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 27 Apr 1998 15:19:17 +0000 (15:19 +0000)
when splithost() returned no useable host, to avoid calling
splituser() on None.

Lib/urllib.py

index 8a47316c9bd40d50b3cc67a520adf99c64a8974b..1f110c0dd4849998cf49de38918c97e2b0efe7f6 100644 (file)
@@ -214,9 +214,11 @@ class URLopener:
        # Use HTTP protocol
        def open_http(self, url, data=None):
                import httplib
+               user_passwd = None
                if type(url) is type(""):
                        host, selector = splithost(url)
-                       user_passwd, host = splituser(host)
+                       if host:
+                               user_passwd, host = splituser(host)
                        realhost = host
                else:
                        host, selector = url
@@ -226,7 +228,9 @@ class URLopener:
                                realhost = None
                        else:
                                realhost, rest = splithost(rest)
-                               user_passwd, realhost = splituser(realhost)
+                               if realhost:
+                                       user_passwd, realhost = \
+                                                    splituser(realhost)
                                if user_passwd:
                                        selector = "%s://%s%s" % (urltype,
                                                                  realhost,