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 tests fail when offline
Type: behavior Stage: resolved
Components: Installation, Library (Lib), Tests Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: benjamin.peterson, ezio.melotti, guandalino, orsenthil, terry.reedy
Priority: normal Keywords:

Created on 2010-08-01 10:30 by guandalino, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
offline.log guandalino, 2010-08-01 10:30 complete log with error
online.log guandalino, 2010-08-01 10:31 complete log success
Messages (4)
msg112307 - (view) Author: Guandalino (guandalino) Date: 2010-08-01 10:30
urllib2 tests fail when internet connection is not available.

$ cd ~/sandbox/2.7/lib/python2.7/test
$ python test_urllib2.py

other output, [cut]

======================================================================
ERROR: test_file (__main__.HandlerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_urllib2.py", line 711, in test_file
    h.file_open, Request(url))
  File "/home/redt/sandbox/2.7/lib/python2.7/unittest/case.py", line 456, in assertRaises
    callableObj(*args, **kwargs)
  File "/home/redt/sandbox/2.7/lib/python2.7/urllib2.py", line 1269, in file_open
    return self.open_local_file(req)
  File "/home/redt/sandbox/2.7/lib/python2.7/urllib2.py", line 1301, in open_local_file
    (not port and socket.gethostbyname(host) in self.get_names()):
gaierror: [Errno -5] No address associated with hostname

----------------------------------------------------------------------
Ran 34 tests in 0.414s

FAILED (errors=1)

The issue verifies using ubuntu 8.04 LTS having this /etc/hosts:

127.0.0.1 localhost localhost.localdomain speedy

::1 localhost speedy ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts 

Note that when connected to internet all the tests pass.

Further details can be found in a thread I started 
on comp.lang.python. http://bit.ly/9x9Umu.

I can't guarantee a quick answer but let me know if other info are required, I'll be glad to provide them asap. Thank you.
msg113556 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-10 20:31
I believe in our python-list discussion you identified the precise line that fails. Please copy it here.
msg113582 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-08-11 03:03
Yes, confirmed it in release27 branch. Gaierror is returned when tests are run offline.
msg113612 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-08-11 18:20
Fixed in r83950 by adding a wrapper function for catching gaierror. It was already present in py3k. 

Thanks for the bug report.
History
Date User Action Args
2022-04-11 14:57:04adminsetgithub: 53691
2010-08-11 18:20:16orsenthilsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg113612

stage: resolved
2010-08-11 03:03:46orsenthilsetassignee: orsenthil
resolution: accepted
messages: + msg113582
2010-08-10 20:31:39terry.reedysetmessages: + msg113556
2010-08-01 10:31:40guandalinosetfiles: + online.log
2010-08-01 10:30:10guandalinocreate