Make socket.getservbyname test optional on socket module having that

attribute.  Jython does not have this function.

Closes SF patch #403667.
This commit is contained in:
Barry Warsaw 2001-03-23 17:40:16 +00:00
parent 6a12d8d3b4
commit 6870bba459
1 changed files with 6 additions and 5 deletions

View File

@ -83,11 +83,12 @@ for name in all_host_names:
else:
print 'FQDN not found'
print socket.getservbyname('telnet', 'tcp')
try:
socket.getservbyname('telnet', 'udp')
except socket.error:
pass
if hasattr(socket, 'getservbyname'):
print socket.getservbyname('telnet', 'tcp')
try:
socket.getservbyname('telnet', 'udp')
except socket.error:
pass
canfork = hasattr(os, 'fork')