]> granicus.if.org Git - python/commitdiff
patch [ 756021 ] Allow socket.inet_aton("255.255.255.255") on Windows
authorGeorg Brandl <georg@python.org>
Fri, 26 Aug 2005 08:34:00 +0000 (08:34 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 26 Aug 2005 08:34:00 +0000 (08:34 +0000)
Lib/test/test_socket.py
Misc/NEWS
Modules/socketmodule.c

index 31ac8920dc2a04de78ddd90fe171ad94e3486564..1899e78d05b8cfb773a314c73095435f7665f9d4 100644 (file)
@@ -380,10 +380,12 @@ class GeneralModuleTests(unittest.TestCase):
         self.assertEquals('\xff\x00\xff\x00', f('255.0.255.0'))
         self.assertEquals('\xaa\xaa\xaa\xaa', f('170.170.170.170'))
         self.assertEquals('\x01\x02\x03\x04', f('1.2.3.4'))
+        self.assertEquals('\xff\xff\xff\xff', f('255.255.255.255'))
 
         self.assertEquals('\x00\x00\x00\x00', g('0.0.0.0'))
         self.assertEquals('\xff\x00\xff\x00', g('255.0.255.0'))
         self.assertEquals('\xaa\xaa\xaa\xaa', g('170.170.170.170'))
+        self.assertEquals('\xff\xff\xff\xff', g('255.255.255.255'))
 
     def testIPv6toString(self):
         if not hasattr(socket, 'inet_pton'):
index 0bb698b44b43f61bc5f5318c62a12c57196ff0eb..5bf94c0d3248752bce167967825e95065e4591dc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -133,9 +133,12 @@ Core and builtins
 Extension Modules
 -----------------
 
-- Bug #1191043: Fix bz2.BZ2File.seek() for 64-bit file offsets.
+- Patch #756021: Special-case socket.inet_aton('255.255.255.255') for
+  platforms that don't have inet_aton().
 
-- Bug #1215928: Fix bz2.BZ2File.(x)readlines for files containing one
+- Bug #1215928: Fix bz2.BZ2File.seek() for 64-bit file offsets.
+
+- Bug #1191043: Fix bz2.BZ2File.(x)readlines for files containing one
   line without newlines.
 
 - Bug #728515: mmap.resize() now resizes the file on Unix as it did
index 3c17e9ce48b38694e4c21177babf90c91925f7b6..059153d3ccc2cce6d674faa1f928beb8b81a7fde 100644 (file)
@@ -3238,14 +3238,19 @@ socket_inet_aton(PyObject *self, PyObject *args)
        return NULL;
 
 #else /* ! HAVE_INET_ATON */
-       /* XXX Problem here: inet_aton('255.255.255.255') raises
-          an exception while it should be a valid address. */
-       packed_addr = inet_addr(ip_addr);
+       /* special-case this address as inet_addr might return INADDR_NONE
+        * for this */
+       if (strcmp(ip_addr, "255.255.255.255") == 0) {
+               packed_addr = 0xFFFFFFFF;
+       } else {
+       
+               packed_addr = inet_addr(ip_addr);
 
-       if (packed_addr == INADDR_NONE) {       /* invalid address */
-               PyErr_SetString(socket_error,
-                       "illegal IP address string passed to inet_aton");
-               return NULL;
+               if (packed_addr == INADDR_NONE) {       /* invalid address */
+                       PyErr_SetString(socket_error,
+                               "illegal IP address string passed to inet_aton");
+                       return NULL;
+               }
        }
        return PyString_FromStringAndSize((char *) &packed_addr,
                                          sizeof(packed_addr));