[Python-checkins] r76022 - in python/branches/release26-maint: Lib/test/test_socket.py Misc/NEWS Modules/socketmodule.c

gregory.p.smith python-checkins at python.org
Sun Nov 1 21:28:48 CET 2009


Author: gregory.p.smith
Date: Sun Nov 1 21:28:48 2009
New Revision: 76022
Log:
Merged revisions 69519 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r69519 | gregory.p.smith | 2009年02月11日 15:45:25 -0800 (2009年2月11日) | 3 lines
 
 Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
 on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Lib/test/test_socket.py
 python/branches/release26-maint/Misc/NEWS
 python/branches/release26-maint/Modules/socketmodule.c
Modified: python/branches/release26-maint/Lib/test/test_socket.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_socket.py	(original)
+++ python/branches/release26-maint/Lib/test/test_socket.py	Sun Nov 1 21:28:48 2009
@@ -385,6 +385,14 @@
 # Check that setting it to an invalid type raises TypeError
 self.assertRaises(TypeError, socket.setdefaulttimeout, "spam")
 
+ def testIPv4_inet_aton_fourbytes(self):
+ if not hasattr(socket, 'inet_aton'):
+ return # No inet_aton, nothing to check
+ # Test that issue1008086 and issue767150 are fixed.
+ # It must return 4 bytes.
+ self.assertEquals('\x00'*4, socket.inet_aton('0.0.0.0'))
+ self.assertEquals('\xff'*4, socket.inet_aton('255.255.255.255'))
+
 def testIPv4toString(self):
 if not hasattr(socket, 'inet_pton'):
 return # No inet_pton() on this platform
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Sun Nov 1 21:28:48 2009
@@ -24,6 +24,9 @@
 Library
 -------
 
+- Issue #1008086: Fixed socket.inet_aton() to always return 4 bytes even on
+ LP64 platforms (most 64-bit Linux, bsd, unix systems).
+
 - Issue #7246 & Issue #7208: getpass now properly flushes input before
 reading from stdin so that existing input does not confuse it and
 lead to incorrect entry or an IOError. It also properly flushes it
Modified: python/branches/release26-maint/Modules/socketmodule.c
==============================================================================
--- python/branches/release26-maint/Modules/socketmodule.c	(original)
+++ python/branches/release26-maint/Modules/socketmodule.c	Sun Nov 1 21:28:48 2009
@@ -3745,8 +3745,11 @@
 #endif
 
 #if !defined(HAVE_INET_ATON) || defined(USE_INET_ATON_WEAKLINK)
+#if (SIZEOF_INT != 4)
+#error "Not sure if in_addr_t exists and int is not 32-bits."
+#endif
 	/* Have to use inet_addr() instead */
-	unsigned long packed_addr;
+	unsigned int packed_addr;
 #endif
 	char *ip_addr;
 
@@ -5284,7 +5287,10 @@
 inet_pton(int af, const char *src, void *dst)
 {
 	if (af == AF_INET) {
-		long packed_addr;
+#if (SIZEOF_INT != 4)
+#error "Not sure if in_addr_t exists and int is not 32-bits."
+#endif
+		unsigned int packed_addr;
 		packed_addr = inet_addr(src);
 		if (packed_addr == INADDR_NONE)
 			return 0;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /