From: SourceForge.net <no...@so...> - 2007-11-19 02:39:28
|
Bugs item #1644000, was opened at 2007-01-24 21:27 Message generated for change (Comment added) made by kitterma You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=403045&aid=1644000&group_id=31674 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: None Group: None >Status: Closed >Resolution: Fixed Priority: 3 Private: No Submitted By: Scott Kitterman (kitterma) Assigned to: Nobody/Anonymous (nobody) Summary: Fails to trap socket.error when network is not available Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: Scott Kitterman (kitterma) Date: 2007-11-18 21:39 Message: Logged In: YES user_id=1300068 Originator: YES Fixed in 2.3.1 ---------------------------------------------------------------------- Comment By: Scott Kitterman (kitterma) Date: 2007-01-24 21:30 Message: 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: ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=403045&aid=1644000&group_id=31674 |