From d687be09b4c691850e160f7daccb8ed9d63551b0 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 27 Mar 2011 16:15:24 +0100 Subject: [PATCH] Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when trying to pack a negative (in-range) integer. --- Lib/test/test_xdrlib.py | 2 ++ Lib/xdrlib.py | 4 +++- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py index ab6e4607bd..9ba8885c0a 100644 --- a/Lib/test/test_xdrlib.py +++ b/Lib/test/test_xdrlib.py @@ -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) diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py index 796dfafd2f..ef172dd37d 100644 --- a/Lib/xdrlib.py +++ b/Lib/xdrlib.py @@ -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): diff --git a/Misc/ACKS b/Misc/ACKS index 66ace9a393..c2bcde2867 100644 --- 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 diff --git a/Misc/NEWS b/Misc/NEWS index 3eb910cbdf..fcd7b63298 100644 --- 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. -- 2.50.1