diff options
author | Guido van Rossum <guido@python.org> | 2007-01-15 00:07:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-15 00:07:32 (GMT) |
commit | 018919aba81093e43d5c5c401a253b0707a8e86f (patch) | |
tree | be6e200e2ee5962ab4d57449ab66dec01442eef7 /Lib | |
parent | 65eabe30e4f3841a32383d9e3dda76573c2b8934 (diff) | |
download | cpython-018919aba81093e43d5c5c401a253b0707a8e86f.zip cpython-018919aba81093e43d5c5c401a253b0707a8e86f.tar.gz cpython-018919aba81093e43d5c5c401a253b0707a8e86f.tar.bz2 |
Merged revisions 53434 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r53434 | guido.van.rossum | 2007-01-14 09:03:32 -0800 (Sun, 14 Jan 2007) | 3 lines
Patch #1635058 by Mark Roberts: ensure that htonl and friends never accept or
return negative numbers, per the underlying C implementation.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_socket.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index e141257..ecfb1ed 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -310,6 +310,20 @@ class GeneralModuleTests(unittest.TestCase): self.assertEqual(swapped & mask, mask) self.assertRaises(OverflowError, func, 1L<<34) + def testNtoHErrors(self): + good_values = [ 1, 2, 3, 1L, 2L, 3L ] + bad_values = [ -1, -2, -3, -1L, -2L, -3L ] + for k in good_values: + socket.ntohl(k) + socket.ntohs(k) + socket.htonl(k) + socket.htons(k) + for k in bad_values: + self.assertRaises(OverflowError, socket.ntohl, k) + self.assertRaises(OverflowError, socket.ntohs, k) + self.assertRaises(OverflowError, socket.htonl, k) + self.assertRaises(OverflowError, socket.htons, k) + def testGetServBy(self): eq = self.assertEqual # Find one service that exists, then check all the related interfaces. |