Simple example that won't work!

Tim Roberts timr at probo.com
Wed Jun 20 01:35:25 EDT 2001


Jay Parlar <jparlar at home.com> wrote:
>
>The error, as stated before, occurs on the call to urlretrieve(), and the exception is as follows:
>
>Traceback (most recent call last):
>  File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line  301, in RunScript
>    exec codeObject in __main__.__dict__
>  File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ?
>    download()
>  File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download
>    retval= urlretrieve(url)[0]
>  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve
>    return _urlopener.retrieve(url, filename, reporthook, data)
>  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve
>    fp = self.open(url, data)
>  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open
>    return getattr(self, name)(url)
>  File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http
>    h = httplib.HTTP(host)
>  File "c:\program files\python20\lib\httplib.py", line 640, in __init__
>    self._conn = self._connection_class(host, port)
>  File "c:\program files\python20\lib\httplib.py", line 330, in __init__
>    self._set_hostport(host, port)
>  File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport
>    port = int(host[i+1:])
>ValueError: invalid literal for int():
>
>Hopefully this is enough information now, and thank you to anyone who's looking at this.

I don't see this on my Win98 machine.  The code at that point is trying to
extract the port number.  It found the ":", but host[i+1:] seems to be
null.  If you want to play with this, you might try inserting some print
statements in set_hostport in httplib.py to print the vaue of host and of i
before that statement.
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list