This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: urllib2 should be more robust for sloppy proxy URLs
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, georg.brandl, lordsutch, spiv
Priority: normal Keywords:

Created on 2004-02-22 10:05 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
urllib2.diff doko, 2004-03-28 13:28
Messages (5)
msg20104 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-02-22 10:05
passing an URL like "" instead of
"" results in a stacktrace:

  File "/usr/lib/python2.3/", line 326, in open
    '_open', req)
  File "/usr/lib/python2.3/", line 306, in
    result = func(*args)
  File "/usr/lib/python2.3/", line 491, in
    lambda r, proxy=url, type=type, meth=self.proxy_open: \
  File "/usr/lib/python2.3/", line 498, in
    if '@' in host:
TypeError: iterable argument required

This could be fixed by calling urlparse.urlparse on the
proxy url, either in the calling code or in the library
code, which I would prefer to make it more robust about
sloppy URLs passed in the http_proxy environment variable.
msg20105 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-02-22 10:19
Logged In: YES 

Ok, I see, PEP42 ...
msg20106 - (view) Author: Chris Lawrence (lordsutch) Date: 2004-03-24 21:51
Logged In: YES 

I've put together a patch, which can be found at; it isn't perfect (ideally the
entire routine should be rewritten, as it's processing
environment data that could be from the "wild"), but it
avoids the traceback.
msg20107 - (view) Author: Andrew Bennetts (spiv) Date: 2006-01-17 03:04
Logged In: YES 

I think test cases would help the patch at get applied.
msg20108 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-21 07:22
Logged In: YES 

I committed a fix (similar to the patch) in rev. 42133 to
the HEAD.

I'm not sure whether to backport.
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39972
2004-02-22 10:05:18dokocreate