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.

classification
Title: urllib2 fails its builtin test
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cjwhrh, georg.brandl, jjlee, quiver
Priority: normal Keywords:

Created on 2003-11-18 12:32 by cjwhrh, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg19022 - (view) Author: Colin J. Williams (cjwhrh) Date: 2003-11-18 12:32
>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
msg19023 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2003-11-18 15:48
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.
msg19024 - (view) Author: Colin J. Williams (cjwhrh) Date: 2003-11-18 22:04
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.
msg19025 - (view) Author: John J Lee (jjlee) Date: 2003-12-03 19:40
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... 
msg19026 - (view) Author: John J Lee (jjlee) Date: 2003-12-08 00:17
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). 
 
msg19027 - (view) Author: John J Lee (jjlee) Date: 2005-05-19 20:22
Logged In: YES 
user_id=261020

This should be closed: this issue was resolved by patch 852995.
msg19028 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-09-15 10:11
Logged In: YES 
user_id=1188172

Closing as requested.
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39563
2003-11-18 12:32:17cjwhrhcreate