summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_xdrlib.py2
-rw-r--r--Lib/xdrlib.py4
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py
index 073448c..6004c9f 100644
--- a/Lib/test/test_xdrlib.py
+++ b/Lib/test/test_xdrlib.py
@@ -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)
diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py
index b293e06..4e48677 100644
--- a/Lib/xdrlib.py
+++ b/Lib/xdrlib.py
@@ -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):
diff --git a/Misc/ACKS b/Misc/ACKS
index 9747ae7..c05da80 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -331,6 +331,7 @@ Duncan Grisby
Fabian Groffen
Eric Groo
Dag Gruneau
+Filip Gruszczyński
Michael Guravage
Lars Gustäbel
Thomas Güttler
diff --git a/Misc/NEWS b/Misc/NEWS
index d3c01e3..019f39b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,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.