]> 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:25:40 +0000 (16:25 +0100)
committerMark Dickinson <mdickinson@enthought.com>
Sun, 27 Mar 2011 15:25:40 +0000 (16:25 +0100)
Lib/test/test_xdrlib.py
Lib/xdrlib.py
Misc/ACKS
Misc/NEWS

index 073448ccee7588bd91c10f369f93126a170c6435..6004c9f1c67c12e5e54bec5b9b2726df7e047016 100644 (file)
@@ -12,6 +12,7 @@ class XDRTest(unittest.TestCase):
         a = [b'what', b'is', b'hapnin', b'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 b293e06a1084db3bf98ff58bea50347c6c8ec84b..4e4867704057247ea6a237eef1906f3a668b72d1 100644 (file)
@@ -50,7 +50,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 17091ebabf13bd740ddc7a6fdc0254064221edf6..7a0982b78bb3a8582888479bc10c1b17c3b9c654 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -303,6 +303,7 @@ Eddy De Greef
 Duncan Grisby
 Fabian Groffen
 Dag Gruneau
+Filip Gruszczyński
 Michael Guravage
 Lars Gustäbel
 Thomas Güttler
index 72da1ac5f219c4764f8745ea0bcba0a89801e69e..0b45ff5ddab9fbba21e83d3e684235187cd24d36 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,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.