summaryrefslogtreecommitdiff
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-12-13 14:34:06 +0000
committerMartin v. Löwis <martin@v.loewis.de>2008-12-13 14:34:06 +0000
commit46d410616d91afbcfff6ac9ece42b01c2cbb86e0 (patch)
treecf3ffad9c1dd18fdc83b815049e3abbbb32207df /Lib/test/test_struct.py
parentec96c0205bb77236bb87e4c1c5295b40a798bde8 (diff)
downloadcpython-git-46d410616d91afbcfff6ac9ece42b01c2cbb86e0.tar.gz
Issue #4228: Pack negative values the same way as 2.4
in struct's L format.
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 7ecb6ac9a0..f13515000f 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -3,6 +3,8 @@ import test.test_support
import struct
import array
import warnings
+warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated",
+ DeprecationWarning)
import sys
ISBIGENDIAN = sys.byteorder == "big"
@@ -535,6 +537,17 @@ def test_1530559():
test_1530559()
+## Issue 4228. Packing a negative unsigned long warns,
+# but then still should give a value with the
+# topmost bit set.
+
+def test_issue4228():
+ # Packing a long may yield either 32 or 64 bits
+ x = struct.pack('L', -1)[:4]
+ vereq(x, '\xff'*4)
+
+test_issue4228()
+
###########################################################################
# Packing and unpacking to/from buffers.