]> granicus.if.org Git - python/commitdiff
FreeBSD's services file contains an additional echo service entry, with
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>
Mon, 12 Jul 2004 12:10:30 +0000 (12:10 +0000)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>
Mon, 12 Jul 2004 12:10:30 +0000 (12:10 +0000)
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.

Lib/test/test_socket.py

index 180d965b09ddf69d52fc3d90d055b2d98555d9e8..adeca569e46fb21b75a7000c8173e44d39cb27d8 100644 (file)
@@ -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