Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#5 Fails to trap socket.error when network is not available

closed-fixed
nobody
None
3
2007-11-19
2007-01-25
Scott Kitterman
No

To replicate this problem, I first stopped networking (sudo sh /etc/init.d/networking stop) and then executed a python program that calls python-dns. Here is the python-dns part of the stack trace:

File "/var/lib/python-support/python2.5/DNS/Base.py", line 173, in req
self.sendUDPRequest(server)
File "/var/lib/python-support/python2.5/DNS/Base.py", line 189, in sendUDPRequest
self.conn()
File "/var/lib/python-support/python2.5/DNS/Base.py", line 137, in conn
self.s.connect((self.ns,self.port))
File "<string>", line 1, in connect
socket.error: (101, 'Network is unreachable')

Looking at the code in Base.py, socket errors on not trapped unlike other errors in the file.

Discussion

    • priority: 5 --> 3
     
  • Logged In: YES
    user_id=1300068
    Originator: YES

    Here's the fix for this issue (which was Ubuntu bug #80360) and Debian bug #378991

    --- python-dns-2.3.0.orig/DNS/Base.py
    +++ python-dns-2.3.0/DNS/Base.py
    @@ -29,7 +29,8 @@
    if not line or line[0]==';' or line[0]=='#':
    continue
    fields=string.split(line)
    - if len(fields) == 0:
    + #Fix Debian bug #378991
    + if len(fields) < 2:
    continue
    if fields[0]=='domain':
    defaults['domain']=fields[1]
    @@ -169,10 +170,14 @@
    1, 0, 0, 0)
    m.addQuestion(qname, qtype, Class.IN)
    self.request = m.getbuf()
    - if protocol == 'udp':
    - self.sendUDPRequest(server)
    - else:
    - self.sendTCPRequest(server)
    + #Trap socket.error - Fix Ubuntu bug #80360
    + try:
    + if protocol == 'udp':
    + self.sendUDPRequest(server)
    + else:
    + self.sendTCPRequest(server)
    + except socket.error, reason:
    + raise DNSError, reason
    if self.async:
    return None
    else:

     
  • Logged In: YES
    user_id=1300068
    Originator: YES

    Fixed in 2.3.1

     
    • status: open --> closed-fixed