summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-11-16 09:39:10 +0200
committerEzio Melotti <ezio.melotti@gmail.com>2011-11-16 09:39:10 +0200
commit11060a4a48811f7f13d8f71b5ece2acda112b6de (patch)
tree7804963ffa2564c0f2f20e208d0b64e8bd22ea7f
parent27c2a861ee83b9e46f560eb02d246e1074fda4f6 (diff)
downloadcpython-git-11060a4a48811f7f13d8f71b5ece2acda112b6de.tar.gz
#13406: silence deprecation warnings in test_codecs.
-rw-r--r--Lib/test/test_codecs.py23
-rw-r--r--Modules/_codecsmodule.c2
-rw-r--r--Objects/unicodeobject.c2
3 files changed, 17 insertions, 10 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index cc5d4bbae2..42c8fcfd69 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1025,17 +1025,22 @@ class UnicodeInternalTest(unittest.TestCase):
for internal, uni in ok:
if sys.byteorder == "little":
internal = bytes(reversed(internal))
- self.assertEqual(uni, internal.decode("unicode_internal"))
+ with support.check_warnings():
+ self.assertEqual(uni, internal.decode("unicode_internal"))
for internal in not_ok:
if sys.byteorder == "little":
internal = bytes(reversed(internal))
- self.assertRaises(UnicodeDecodeError, internal.decode,
- "unicode_internal")
+ with support.check_warnings(('unicode_internal codecs has been '
+ 'deprecated', DeprecationWarning)):
+ self.assertRaises(UnicodeDecodeError, internal.decode,
+ "unicode_internal")
@unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t')
def test_decode_error_attributes(self):
try:
- b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal")
+ with support.check_warnings(('unicode_internal codecs has been '
+ 'deprecated', DeprecationWarning)):
+ b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal")
except UnicodeDecodeError as ex:
self.assertEqual("unicode_internal", ex.encoding)
self.assertEqual(b"\x00\x00\x00\x00\x00\x11\x11\x00", ex.object)
@@ -1048,10 +1053,12 @@ class UnicodeInternalTest(unittest.TestCase):
def test_decode_callback(self):
codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
decoder = codecs.getdecoder("unicode_internal")
- ab = "ab".encode("unicode_internal").decode()
- ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
- "ascii"),
- "UnicodeInternalTest")
+ with support.check_warnings(('unicode_internal codecs has been '
+ 'deprecated', DeprecationWarning)):
+ ab = "ab".encode("unicode_internal").decode()
+ ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
+ "ascii"),
+ "UnicodeInternalTest")
self.assertEqual(("ab", 12), ignored)
def test_encode_length(self):
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 58ffc1d035..4cd5c23fec 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -688,7 +688,7 @@ unicode_internal_encode(PyObject *self,
return NULL;
if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "unicode_internal codecs has been deprecated",
+ "unicode_internal codec has been deprecated",
1))
return NULL;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index cdad738d47..a0459a07b6 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6235,7 +6235,7 @@ _PyUnicode_DecodeUnicodeInternal(const char *s,
PyObject *exc = NULL;
if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "unicode_internal codecs has been deprecated",
+ "unicode_internal codec has been deprecated",
1))
return NULL;