summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-07-07 15:08:28 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-07-07 15:08:28 (GMT)
commit5fd3af24a25ff7fd6d87fb521cdd2b5f5c5d32ee (patch)
tree25844eac6894374a1a6f69555562a2f266fec14d /Lib/test/test_struct.py
parentbb3895cfc63d2ac0df6d15c5d25ed4862f3b9d03 (diff)
downloadcpython-5fd3af24a25ff7fd6d87fb521cdd2b5f5c5d32ee.zip
cpython-5fd3af24a25ff7fd6d87fb521cdd2b5f5c5d32ee.tar.gz
cpython-5fd3af24a25ff7fd6d87fb521cdd2b5f5c5d32ee.tar.bz2
Issue #1523: Remove deprecated overflow masking in struct module, and
make sure that out-of-range values consistently raise struct.error.
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py20
1 files changed, 1 insertions, 19 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index ca85f8f..556a576 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -26,12 +26,8 @@ else:
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):
@@ -54,20 +50,6 @@ def with_warning_restore(func):
return func(*args, **kw)
return decorator
-@with_warning_restore
-def deprecated_err(func, *args):
- try:
- func(*args)
- except (struct.error, OverflowError):
- pass
- except DeprecationWarning:
- if not PY_STRUCT_OVERFLOW_MASKING:
- raise TestFailed, "%s%s expected to raise DeprecationWarning" % (
- func.__name__, args)
- else:
- raise TestFailed, "%s%s did not raise error" % (
- func.__name__, args)
-
class StructTest(unittest.TestCase):
@with_warning_restore
@@ -289,7 +271,7 @@ class StructTest(unittest.TestCase):
'\x01' + got)
else:
# x is out of range -- verify pack realizes that.
- deprecated_err(pack, format, x)
+ self.assertRaises(struct.error, pack, format, x)
def run(self):
from random import randrange