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

SourceForge.net noreply at sourceforge.net
Tue Nov 18 17:04:11 EST 2003


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

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
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: Colin J. Williams (cjwhrh)
Date: 2003-11-18 17: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 10: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