Issue1626

classification
Title: urllib.urlretrieve doesn't work with 1 or 2 argument version
Type: behaviour Severity: normal
Components: Library Versions: 2.5.1
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: amak Nosy List: amak, jheiselman, zyasoft
Priority: Keywords:

Created on 2010-07-01.19:17:44 by jheiselman, last changed 2010-07-19.22:56:08 by zyasoft.

Messages
msg5867 (view) Author: Jerry (jheiselman) Date: 2010-07-01.19:17:42
I cannot seem to get urlretrieve to function the way it should.  No matter what URL I give it, it gives this error.  The 2 argument version (for saving to a named file) throws the same error.

Platform information:
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.5.0_22


>>> urllib.urlretrieve("http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/50594/chrome-win32.zip")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\jython\jython.jar\Lib\urllib.py", line 89, in urlretrieve
  File "C:\jython\jython.jar\Lib\urllib.py", line 222, in retrieve
  File "C:\jython\jython.jar\Lib\urllib.py", line 180, in open
TypeError: cannot concatenate 'str' and 'NoneType' objects
msg5869 (view) Author: Alan Kennedy (amak) Date: 2010-07-02.17:39:44
Works for me.

Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.5.0_21
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlretrieve("http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/50594/chrome-win32.zip", "chrome.zip")
('chrome.zip', <httplib.HTTPMessage instance at 0x1>)
>>>

Results in a local file named "chrome.zip", 23,999,591 bytes long.

What does the following print on your system?

import urllib
url = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/50594/chrome-win32.zip"
print urllib.splittype(url)

On mine, it prints

('http', '//build.chromium.org/buildbot/snapshots/chromium-rel-xp/50594/chrome-win32.zip')
msg5875 (view) Author: Jerry (jheiselman) Date: 2010-07-06.20:01:49
Output as requested:

Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.5.0_22
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> url = "http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/50594/chrome-win32.zip"
>>> print urllib.splittype(url)
('http', '//build.chromium.org/buildbot/snapshots/chromium-rel-xp/50594/chrome-win32.zip')

Looks like it is parsing it properly on my system.

I've tracked the problem to the proxy code in urllib.py.  The HTTP_proxy variable on my system didn't have the urltype (i.e. http) in the value.  This doesn't seem to be a problem for my perl code, but it definitely is in the urllib module.  Redefining it as http://<proxyaddress> worked great.

I think we can close this as user error.
msg5906 (view) Author: Jim Baker (zyasoft) Date: 2010-07-19.22:56:08
Closed per discussion on #jython
History
Date User Action Args
2010-07-19 22:56:08zyasoftsetstatus: open -> closed
nosy: + zyasoft
messages: + msg5906
2010-07-06 20:01:50jheiselmansetmessages: + msg5875
2010-07-02 17:39:45amaksetassignee: amak
messages: + msg5869
nosy: + amak
2010-07-01 19:17:44jheiselmancreate