#4228: Pack negative values the same way as 2.4
in struct's L format.
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 232bffc..7f5f08b 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -2,6 +2,8 @@
import unittest
import struct
import warnings
+warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated",
+ DeprecationWarning)
from functools import wraps
from test.test_support import TestFailed, verbose, run_unittest
@@ -461,6 +463,11 @@
self.check_float_coerce(endian + fmt, 1.0)
self.check_float_coerce(endian + fmt, 1.5)
+ def test_issue4228(self):
+ # Packing a long may yield either 32 or 64 bits
+ x = struct.pack('L', -1)[:4]
+ self.assertEqual(x, '\xff'*4)
+
def test_unpack_from(self):
test_string = 'abcd01234'
fmt = '4s'