Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79a9036

Browse files
committed
Merge #9696
2 parents ea8e208 + 92b60d5 commit 79a9036

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/test/test_xdrlib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def test_xdr(self):
1212
a = [b'what', b'is', b'hapnin', b'doctor']
1313

1414
p.pack_int(42)
15+
p.pack_int(-17)
1516
p.pack_uint(9)
1617
p.pack_bool(True)
1718
p.pack_bool(False)
@@ -29,6 +30,7 @@ def test_xdr(self):
2930
self.assertEqual(up.get_position(), 0)
3031

3132
self.assertEqual(up.unpack_int(), 42)
33+
self.assertEqual(up.unpack_int(), -17)
3234
self.assertEqual(up.unpack_uint(), 9)
3335
self.assertTrue(up.unpack_bool() is True)
3436

Lib/xdrlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def get_buffer(self):
5050
def pack_uint(self, x):
5151
self.__buf.write(struct.pack('>L', x))
5252

53-
pack_int = pack_uint
53+
def pack_int(self, x):
54+
self.__buf.write(struct.pack('>l', x))
55+
5456
pack_enum = pack_int
5557

5658
def pack_bool(self, x):

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ Duncan Grisby
331331
Fabian Groffen
332332
Eric Groo
333333
Dag Gruneau
334+
Filip Gruszczyński
334335
Michael Guravage
335336
Lars Gustäbel
336337
Thomas Güttler

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Core and Builtins
4949
Library
5050
-------
5151

52+
- Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when
53+
trying to pack a negative (in-range) integer.
54+
5255
- Issue #11675: multiprocessing.[Raw]Array objects created from an integer size
5356
are now zeroed on creation. This matches the behaviour specified by the
5457
documentation.

0 commit comments

Comments
 (0)