Commit 5476cbe2 authored by Mark Dickinson's avatar Mark Dickinson

Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when...

Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when trying to pack a negative (in-range) integer.
parent 64200c58
...@@ -12,6 +12,7 @@ class XDRTest(unittest.TestCase): ...@@ -12,6 +12,7 @@ class XDRTest(unittest.TestCase):
a = [b'what', b'is', b'hapnin', b'doctor'] a = [b'what', b'is', b'hapnin', b'doctor']
p.pack_int(42) p.pack_int(42)
p.pack_int(-17)
p.pack_uint(9) p.pack_uint(9)
p.pack_bool(True) p.pack_bool(True)
p.pack_bool(False) p.pack_bool(False)
...@@ -29,6 +30,7 @@ class XDRTest(unittest.TestCase): ...@@ -29,6 +30,7 @@ class XDRTest(unittest.TestCase):
self.assertEqual(up.get_position(), 0) self.assertEqual(up.get_position(), 0)
self.assertEqual(up.unpack_int(), 42) self.assertEqual(up.unpack_int(), 42)
self.assertEqual(up.unpack_int(), -17)
self.assertEqual(up.unpack_uint(), 9) self.assertEqual(up.unpack_uint(), 9)
self.assertTrue(up.unpack_bool() is True) self.assertTrue(up.unpack_bool() is True)
......
...@@ -50,7 +50,9 @@ class Packer: ...@@ -50,7 +50,9 @@ class Packer:
def pack_uint(self, x): def pack_uint(self, x):
self.__buf.write(struct.pack('>L', 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 pack_enum = pack_int
def pack_bool(self, x): def pack_bool(self, x):
......
...@@ -303,6 +303,7 @@ Eddy De Greef ...@@ -303,6 +303,7 @@ Eddy De Greef
Duncan Grisby Duncan Grisby
Fabian Groffen Fabian Groffen
Dag Gruneau Dag Gruneau
Filip Gruszczyński
Michael Guravage Michael Guravage
Lars Gustäbel Lars Gustäbel
Thomas Güttler Thomas Güttler
......
...@@ -44,6 +44,9 @@ Core and Builtins ...@@ -44,6 +44,9 @@ Core and Builtins
Library 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 - Issue #11675: multiprocessing.[Raw]Array objects created from an integer size
are now zeroed on creation. This matches the behaviour specified by the are now zeroed on creation. This matches the behaviour specified by the
documentation. documentation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment