summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-01 12:15:31 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-01 12:15:31 (GMT)
commit6269fec171191a38e418dc6b94697ca4fe6e4160 (patch)
tree9f3999fff773c450ef8a3873069e22cc4a69381a /Lib
parent775c30706882291fe6385066899f702f768ed95f (diff)
downloadcpython-6269fec171191a38e418dc6b94697ca4fe6e4160.zip
cpython-6269fec171191a38e418dc6b94697ca4fe6e4160.tar.gz
cpython-6269fec171191a38e418dc6b94697ca4fe6e4160.tar.bz2
#4228: Pack negative values the same way as 2.4
in struct's L format.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_struct.py7
1 files changed, 7 insertions, 0 deletions
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 array
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 @@ class StructTest(unittest.TestCase):
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'