mirror of
https://github.com/python/cpython.git
synced 2024-12-14 20:34:12 +08:00
FreeBSD's services file contains an additional echo service entry, with
a non-standard protocol and on a lower port than the tcp/udp entries, which breaks the assumption that there will only be one service by a given name on a given port when no protocol is specified. Previous versions of this code have had other problems as a result of different service definitions amongst common platforms. As this platform has an extra, unexpected, service entry, I've special cased the platform rather than re-order the list of services checked to highlight the pitfall.
This commit is contained in:
parent
fd4984d1fc
commit
18bf43c4a4
@ -289,7 +289,13 @@ class GeneralModuleTests(unittest.TestCase):
|
||||
# Find one service that exists, then check all the related interfaces.
|
||||
# I've ordered this by protocols that have both a tcp and udp
|
||||
# protocol, at least for modern Linuxes.
|
||||
for service in ('echo', 'daytime', 'domain'):
|
||||
if sys.platform in ('freebsd4', 'freebsd5'):
|
||||
# avoid the 'echo' service on this platform, as there is an
|
||||
# assumption breaking non-standard port/protocol entry
|
||||
services = ('daytime', 'qotd', 'domain')
|
||||
else:
|
||||
services = ('echo', 'daytime', 'domain')
|
||||
for service in services:
|
||||
try:
|
||||
port = socket.getservbyname(service, 'tcp')
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user