urllib2 problem with ports.

Ant antroy at gmail.com
Thu Jun 15 13:58:02 EDT 2006


Hi all,

I have just moved to a new machine, and so have installed the latest
version of Python (2.4.3 - previously I believe I was running 2.4.2).
Unfortunately this seems to have broken urllib2...

An app I wrote for testing our web application makes heavy use of
urllib2 against the localhost, and I am getting the following problem
(minimal code sample):

#/usr/bin/python
import urllib2

urllib2.urlopen("http://localhost:8080/")

This gives the output (Stack trace snipped - can post if required):

urllib2.HTTPError: HTTP Error 502: Proxy Error ( The Uniform Resource
Locator (U
RL) does not use a recognized protocol. Either the protocol is not
supported or
the request was not typed correctly. Confirm that a valid protocol is
in use (fo
r example, HTTP for a Web request).  )

This I believe is a problem with the addition of a non-default port.
Replace the url with "http://google.com" for example, and all is well.

Any ideas for workarounds? Or do I roll back to 2.4.2?




More information about the Python-list mailing list