BIND 10 #167: configure addresses and ports to listen on for DNS servers
BIND 10 Development
do-not-reply at isc.org
Wed May 26 00:11:39 UTC 2010
#167: configure addresses and ports to listen on for DNS servers
--------------------------+-------------------------------------------------
Reporter: larissas | Owner: each
Type: task | Status: reviewing
Priority: major | Milestone: 04. 2nd Incremental Release
Component: Unclassified | Resolution:
Keywords: | Sensitive: 0
--------------------------+-------------------------------------------------
Comment(by jinmei):
Replying to [comment:10 each]:
> > Decent level programmers can probably figure out what this code does,
but that wouldn't be immediately obvious. And, due to the nested
conditions it's not so easy to be confident that this code does what it's
supposed to do from a glance.
>
> If nesting is the problem, there are other ways to structure it. Could
have a series of try...except statements with "pass" in each of the
excepts, for instance. Or this:
The real problem is complexity that makes the code difficult to
understand. The nesting is just one source of the complexity. This one
is better than the previous one, but is still complex. We need to follow
the logic with the mixture of for, try, except, continue, raise, wondering
"what if we hit the contine then an exception is thrown, is that safe?"
etc.
{{{
for family in (socket.AF_INET, socket.AF_INET6):
try:
a = socket.inet_pton(family, addr)
self.family = family
self.addr = a
return
except socket.error:
continue
except Exception as e:
raise e
raise socket.error('Invalid IP address')
}}}
I simply don't understand why you want to try so hard making the complex
logic correct while you can do this with just a couple of lines with
getaddrinfo. There should probably be something we never agree with, and,
as I said, this wouldn't be that important anyway and we can use our time
for something more important. So go ahead with whatever code you want
(but please don't forget writing tests to make sure the complex logic does
the right thing).
--
Ticket URL: <https://bind10.isc.org/ticket/167#comment:11>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list