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

Skip to content

Commit 92b60d5

Browse files
committed
Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when trying to pack a negative (in-range) integer.
1 parent ccd2283 commit 92b60d5

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
@@ -303,6 +303,7 @@ Eddy De Greef
303303
Duncan Grisby
304304
Fabian Groffen
305305
Dag Gruneau
306+
Filip Gruszczyński
306307
Michael Guravage
307308
Lars Gustäbel
308309
Thomas Güttler

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Core and Builtins
4444
Library
4545
-------
4646

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

0 commit comments

Comments
 (0)