[ python-Bugs-844336 ] urllib2 fails its builtin test

SourceForge.net noreply at sourceforge.net
Thu Sep 15 12:11:00 CEST 2005


Bugs item #844336, was opened at 2003-11-18 13:32
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=844336&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Colin J. Williams (cjwhrh)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2 fails its builtin test

Initial Comment:
>python -u "ftplib.py"
Traceback (most recent call last):
  File "ftplib.py", line 803, in ?
    test()
  File "ftplib.py", line 762, in test
    while sys.argv[1] == '-d':
IndexError: list index out of range
>Exit code: 1
>python -u "urllib2.py"
gopher://gopher.lib.ncsu.edu/11/library/stacks/Alex
socket.error: (7, 'getaddrinfo failed')

gopher://gopher.vt.edu:10010/10/33
socket.error: (7, 'getaddrinfo failed')

file:/etc/passwd
Traceback (most recent call last):
  File "urllib2.py", line 1154, in ?
    f = urlopen(url, req)
  File "urllib2.py", line 136, in urlopen
    return _opener.open(url, data)
  File "urllib2.py", line 333, in open
    '_open', req)
  File "urllib2.py", line 313, in _call_chain
    result = func(*args)
  File "urllib2.py", line 928, in file_open
    return self.open_local_file(req)
  File "urllib2.py", line 943, in open_local_file
    stats = os.stat(localfile)
OSError: [Errno 2] No such file or directory:
'\etc\passwd'
>Exit code: 1


----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-09-15 12:11

Message:
Logged In: YES 
user_id=1188172

Closing as requested.

----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2005-05-19 22:22

Message:
Logged In: YES 
user_id=261020

This should be closed: this issue was resolved by patch 852995.


----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2003-12-08 01:17

Message:
Logged In: YES 
user_id=261020

Sorry, last comment not very useful. 
 
I think this should be closed. 
 
Two real problems: 
 
1. urllib2.urlopen incorrectly raises OSError instead of 
URLError.  This is already detected by my unit tests (852995), 
and I'll file a separate bug for this later (when/if 852995 is 
resolved). 
 
2. Would be nice if urllib2's functional tests used PyUnit (so it 
is clear which tests are passing or failing), and worked on 
Windows.  Again, I'll submit a separate patch. 
 
To the bug poster: 
 
0. ftplib is not urllib2, please report bugs separately. 
 
1. You're not invoking ftplib's test program correctly.  It seems 
to work, at least partially: 
 
python ftplib.py ftp.python.org /pub/www.python.org/index.html 
 
2. It seems you're using Windows, so you shouldn't expect 
opening /etc/password to work (though the test shouldn't crash 
as it does, of course, and it should work on Windows, and it 
should give an indication of pass/fail). 
 

----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2003-12-03 20:40

Message:
Logged In: YES 
user_id=261020

It is broken.  I'd like to know where functional tests officially 
live before fixing it.  I'll ask on python-dev... 

----------------------------------------------------------------------

Comment By: Colin J. Williams (cjwhrh)
Date: 2003-11-18 23:04

Message:
Logged In: YES 
user_id=285587

This is a response to quiver.

Thanks for pointing out the correct usage of ftlib, I am
slowly sorting out how to use ftplib from a script.

Unfortunately my report did not make it clear that there is
a problem with the operation of the test function.

Usually, a test function gives some assurance that the main
code of the module is functional.  In this case, the test fails.

That, I suggest, indicates a bug.  The bug could be in test
function or the module being exercised.

You are probably right that a host needs to be specified.  I
suggest that the test function should be responsible for this.

Incidentally, it would be very helpful to the potential user
if the documentation made the names and roles of the various
cmds's clearer.

----------------------------------------------------------------------

Comment By: George Yoshida (quiver)
Date: 2003-11-18 16:48

Message:
Logged In: YES 
user_id=671362

For the first one, you need to specify a host to run the 
test.

For expample,
  >python ftplib.py ftp.python.org -l
This gives
  drwxrwxr-x   5 webmaster webmaster      512 Jan 25  
2003 pub

There is a usage on the test in the script:
'''Test program.
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] 
[file] ...'''

I think this is not a bug.


For the second one, catching OSError along with IOError 
might be needed.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=844336&group_id=5470


More information about the Python-bugs-list mailing list