]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when trying...
authorMark Dickinson <mdickinson@enthought.com>
Sun, 27 Mar 2011 15:15:24 +0000 (16:15 +0100)
committerMark Dickinson <mdickinson@enthought.com>
Sun, 27 Mar 2011 15:15:24 +0000 (16:15 +0100)
Lib/test/test_xdrlib.py
Lib/xdrlib.py
Misc/ACKS
Misc/NEWS

index ab6e4607bd7f2935ecd12d223016abec58ddf8cf..9ba8885c0aa292e828a2ce793fde259f205d349c 100644 (file)
@@ -12,6 +12,7 @@ class XDRTest(unittest.TestCase):
         a = ['what', 'is', 'hapnin', 'doctor']
 
         p.pack_int(42)
+        p.pack_int(-17)
         p.pack_uint(9)
         p.pack_bool(True)
         p.pack_bool(False)
@@ -29,6 +30,7 @@ class XDRTest(unittest.TestCase):
         self.assertEqual(up.get_position(), 0)
 
         self.assertEqual(up.unpack_int(), 42)
+        self.assertEqual(up.unpack_int(), -17)
         self.assertEqual(up.unpack_uint(), 9)
         self.assertTrue(up.unpack_bool() is True)
 
index 796dfafd2fff6489c0e083edd38cbcebb32eaf8d..ef172dd37d68b50bc369221c61e7e95f6e36e51a 100644 (file)
@@ -53,7 +53,9 @@ class Packer:
     def pack_uint(self, x):
         self.__buf.write(struct.pack('>L', x))
 
-    pack_int = pack_uint
+    def pack_int(self, x):
+        self.__buf.write(struct.pack('>l', x))
+
     pack_enum = pack_int
 
     def pack_bool(self, x):
index 66ace9a3933013535d4b2cd4ae7abdb722fc24b6..c2bcde286785877237051f23d44c1dd9e6f7fd43 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -306,6 +306,7 @@ Eddy De Greef
 Duncan Grisby
 Fabian Groffen
 Dag Gruneau
+Filip Gruszczyński
 Michael Guravage
 Lars Gustäbel
 Thomas Güttler
index 3eb910cbdf1339006f9d8c930c2f83bc4ed43ce7..fcd7b632984363f27dae5d71cce37cfb31cd0f51 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -47,6 +47,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when
+  trying to pack a negative (in-range) integer.
+
 - Issue #11675: multiprocessing.[Raw]Array objects created from an integer size
   are now zeroed on creation.  This matches the behaviour specified by the
   documentation.