[Python-checkins] cpython: #13406: silence deprecation warnings in test_codecs.
ezio.melotti
python-checkins at python.org
Wed Nov 16 08:39:33 CET 2011
http://hg.python.org/cpython/rev/4f534cd40f54
changeset: 73588:4f534cd40f54
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Wed Nov 16 09:39:10 2011 +0200
summary:
#13406: silence deprecation warnings in test_codecs.
files:
Lib/test/test_codecs.py | 23 +++++++++++++++--------
Modules/_codecsmodule.c | 2 +-
Objects/unicodeobject.c | 2 +-
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1025,17 +1025,22 @@
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 @@
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
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -688,7 +688,7 @@
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
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6235,7 +6235,7 @@
PyObject *exc = NULL;
if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "unicode_internal codecs has been deprecated",
+ "unicode_internal codec has been deprecated",
1))
return NULL;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list