summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-03-21 10:26:31 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-03-21 10:26:31 (GMT)
commitae681df4d8a0edf22a60e853d519c42012c31983 (patch)
treeac82dce2c3d3615e476e383968aff0370861b806 /Lib/test/test_struct.py
parente43b060b05e3d99f83bc900e5efc5cdb34298888 (diff)
downloadcpython-ae681df4d8a0edf22a60e853d519c42012c31983.zip
cpython-ae681df4d8a0edf22a60e853d519c42012c31983.tar.gz
cpython-ae681df4d8a0edf22a60e853d519c42012c31983.tar.bz2
- Issue #5463: In struct module, remove deprecated overflow wrapping
when packing an integer: for example, struct.pack('=L', -1) now raises struct.error instead of returning b'\xff\xff\xff\xff'. Thanks Andreas Schawo for the patch.
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 3d5e028..1d10b8f 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -2,8 +2,6 @@ import array
import unittest
import struct
import warnings
-warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated",
- DeprecationWarning)
from functools import wraps
from test.support import TestFailed, verbose, run_unittest
@@ -17,11 +15,9 @@ try:
import _struct
except ImportError:
PY_STRUCT_RANGE_CHECKING = 0
- PY_STRUCT_OVERFLOW_MASKING = 1
PY_STRUCT_FLOAT_COERCE = 2
else:
PY_STRUCT_RANGE_CHECKING = getattr(_struct, '_PY_STRUCT_RANGE_CHECKING', 0)
- PY_STRUCT_OVERFLOW_MASKING = getattr(_struct, '_PY_STRUCT_OVERFLOW_MASKING', 0)
PY_STRUCT_FLOAT_COERCE = getattr(_struct, '_PY_STRUCT_FLOAT_COERCE', 0)
def string_reverse(s):
@@ -51,8 +47,7 @@ def deprecated_err(func, *args):
except (struct.error, OverflowError):
pass
except DeprecationWarning:
- if not PY_STRUCT_OVERFLOW_MASKING:
- raise TestFailed("%s%s expected to raise DeprecationWarning" % (
+ raise TestFailed("%s%s expected to raise DeprecationWarning" % (
func.__name__, args))
else:
raise TestFailed("%s%s did not raise error" % (
@@ -471,11 +466,6 @@ 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, b'\xff'*4)
-
def test_unpack_from(self):
test_string = b'abcd01234'
fmt = '4s'