diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-04-03 04:49:12 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-04-03 04:49:12 (GMT) |
commit | 7fb697b5d26b1c9a379978653db97a84d7270141 (patch) | |
tree | 322bdf5813ad18b0fc17635fbdf6f2301690d2d6 /Lib | |
parent | 1e469c5603549310699dbfcb66dd38a7ccd3b404 (diff) | |
download | cpython-7fb697b5d26b1c9a379978653db97a84d7270141.zip cpython-7fb697b5d26b1c9a379978653db97a84d7270141.tar.gz cpython-7fb697b5d26b1c9a379978653db97a84d7270141.tar.bz2 |
Revert Patch #670715: iconv support.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/encodings/__init__.py | 5 | ||||
-rw-r--r-- | Lib/encodings/iconv_codec.py | 34 | ||||
-rwxr-xr-x | Lib/test/regrtest.py | 4 | ||||
-rw-r--r-- | Lib/test/test_iconv_codecs.py | 99 |
4 files changed, 0 insertions, 142 deletions
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py index e312fb8..a214190 100644 --- a/Lib/encodings/__init__.py +++ b/Lib/encodings/__init__.py @@ -121,8 +121,3 @@ def search_function(encoding): # Register the search_function in the Python codec registry codecs.register(search_function) -# Register iconv_codec lookup function if available -try: - import iconv_codec -except (ImportError, RuntimeError): - pass diff --git a/Lib/encodings/iconv_codec.py b/Lib/encodings/iconv_codec.py deleted file mode 100644 index 8bd0c3f..0000000 --- a/Lib/encodings/iconv_codec.py +++ /dev/null @@ -1,34 +0,0 @@ -""" Python 'iconv' Codec - - -Written by Hye-Shik Chang (perky@FreeBSD.org). - -Copyright(c) Python Software Foundation, All Rights Reserved. NO WARRANTY. - -""" - -import _iconv_codec -import codecs - -def lookup(enc): - class IconvCodec(_iconv_codec.iconvcodec, codecs.Codec): - encoding = enc - - try: - c = IconvCodec() - - class IconvStreamReader(IconvCodec, codecs.StreamReader): - __init__ = codecs.StreamReader.__init__ - class IconvStreamWriter(IconvCodec, codecs.StreamWriter): - __init__ = codecs.StreamWriter.__init__ - - return ( - c.encode, c.decode, - IconvStreamReader, IconvStreamWriter - ) - except ValueError: - return None - -codecs.register(lookup) - -# ex: ts=8 sts=4 et diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 818b4aa..4ec2855 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -569,7 +569,6 @@ _expectations = { test_gdbm test_gl test_grp - test_iconv_codecs test_imgfile test_ioctl test_largefile @@ -626,7 +625,6 @@ _expectations = { test_fork1 test_gl test_grp - test_iconv_codecs test_ioctl test_imgfile test_largefile @@ -774,7 +772,6 @@ _expectations = { test_email_codecs test_gdbm test_gl - test_iconv_codecs test_imgfile test_largefile test_linuxaudiodev @@ -890,7 +887,6 @@ _expectations = { test_dl test_email_codecs test_gl - test_iconv_codecs test_imgfile test_largefile test_linuxaudiodev diff --git a/Lib/test/test_iconv_codecs.py b/Lib/test/test_iconv_codecs.py deleted file mode 100644 index 9d27faa..0000000 --- a/Lib/test/test_iconv_codecs.py +++ /dev/null @@ -1,99 +0,0 @@ -from test import test_support -import unittest, sys -import codecs, _iconv_codec -from encodings import iconv_codec -from StringIO import StringIO - -class IconvCodecTest(unittest.TestCase): - - if sys.byteorder == 'big': - spam = '\x00s\x00p\x00a\x00m' * 2 - else: - spam = 's\x00p\x00a\x00m\x00' * 2 - - def test_sane(self): - # FIXME: Commented out, because it's not clear whether - # the internal encoding choosen requires byte swapping - # for this iconv() implementation. - if False: - self.encoder, self.decoder, self.reader, self.writer = \ - codecs.lookup(_iconv_codec.internal_encoding) - self.assertEqual(self.decoder(self.spam), (u'spamspam', 16)) - self.assertEqual(self.encoder(u'spamspam'), (self.spam, 8)) - self.assertEqual(self.reader(StringIO(self.spam)).read(), u'spamspam') - f = StringIO() - self.writer(f).write(u'spamspam') - self.assertEqual(f.getvalue(), self.spam) - - def test_basic_errors(self): - self.encoder, self.decoder, self.reader, self.writer = \ - iconv_codec.lookup("ascii") - def testencerror(errors): - return self.encoder(u'sp\ufffdam', errors) - def testdecerror(errors): - return self.decoder('sp\xffam', errors) - - self.assertRaises(UnicodeEncodeError, testencerror, 'strict') - self.assertRaises(UnicodeDecodeError, testdecerror, 'strict') - self.assertEqual(testencerror('replace'), ('sp?am', 5)) - self.assertEqual(testdecerror('replace'), (u'sp\ufffdam', 5)) - self.assertEqual(testencerror('ignore'), ('spam', 5)) - self.assertEqual(testdecerror('ignore'), (u'spam', 5)) - - def test_pep293_errors(self): - self.encoder, self.decoder, self.reader, self.writer = \ - iconv_codec.lookup("ascii") - def testencerror(errors): - return self.encoder(u'sp\ufffdam', errors) - def testdecerror(errors): - return self.decoder('sp\xffam', errors) - - self.assertEqual(testencerror('xmlcharrefreplace'), - ('sp�am', 5)) - self.assertEqual(testencerror('backslashreplace'), - ('sp\\ufffdam', 5)) - - def error_bomb(exc): - return (u'*'*40, len(exc.object)) - def error_mock(exc): - error_mock.lastexc = exc - return (unicode(exc.object[exc.start - 1]), exc.end) - - codecs.register_error('test_iconv_codec.bomb', error_bomb) - codecs.register_error('test_iconv_codec.mock', error_mock) - - self.assertEqual(testencerror('test_iconv_codec.bomb'), - ('sp' + ('*'*40), 5)) - self.assertEqual(testdecerror('test_iconv_codec.bomb'), - (u'sp' + (u'*'*40), 5)) - - self.assertEqual(testencerror('test_iconv_codec.mock'), ('sppam', 5)) - exc = error_mock.lastexc - self.assertEqual(exc.object, u'sp\ufffdam') - self.assertEqual(exc.start, 2) - self.assertEqual(exc.end, 3) - self.assert_(isinstance(exc, UnicodeEncodeError)) - - self.assertEqual(testdecerror('test_iconv_codec.mock'), (u'sppam', 5)) - exc = error_mock.lastexc - self.assertEqual(exc.object, 'sp\xffam') - self.assertEqual(exc.start, 2) - self.assertEqual(exc.end, 3) - self.assert_(isinstance(exc, UnicodeDecodeError)) - - def test_empty_escape_decode(self): - self.encoder, self.decoder, self.reader, self.writer = \ - iconv_codec.lookup("ascii") - self.assertEquals(self.decoder(u""), ("", 0)) - self.assertEquals(self.encoder(""), (u"", 0)) - -def test_main(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(IconvCodecTest)) - test_support.run_suite(suite) - - -if __name__ == "__main__": - test_main() - -# ex: ts=8 sts=4 et |