mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Issue #4228: Pack negative values the same way as 2.4
in struct's L format.
This commit is contained in:
parent
ec96c0205b
commit
46d410616d
3 changed files with 21 additions and 6 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue