Lines Matching refs:codecs

3 import codecs
39 r = codecs.getreader(self.encoding)(q)
51 d = codecs.getincrementaldecoder(self.encoding)()
74 u"".join(codecs.iterdecode(encoded, self.encoding))
80 return codecs.getreader(self.encoding)(stream)
144 return codecs.getreader(self.encoding)(stream)
249 reader = codecs.getreader(self.encoding)(stream)
255 writer = codecs.getwriter(self.encoding)(q)
256 reader = codecs.getreader(self.encoding)(q)
287 reader = codecs.getreader(self.encoding)(stream)
302 reader = codecs.getreader(self.encoding)(stream)
321 _,_,reader,writer = codecs.lookup(self.encoding)
337 f = codecs.getreader(self.encoding)(s)
341 f = codecs.getreader(self.encoding)(s)
377 codecs.utf_32_decode('\x01', 'replace', True))
379 codecs.utf_32_decode('\x01', 'ignore', True))
382 self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
390 codecs.utf_32_decode(encoded_le)[0])
393 codecs.utf_32_decode(encoded_be)[0])
429 self.assertRaises(UnicodeDecodeError, codecs.utf_32_le_decode,
437 codecs.utf_32_le_decode(encoded)[0])
473 self.assertRaises(UnicodeDecodeError, codecs.utf_32_be_decode,
481 codecs.utf_32_be_decode(encoded)[0])
491 _,_,reader,writer = codecs.lookup(self.encoding)
507 f = codecs.getreader(self.encoding)(s)
511 f = codecs.getreader(self.encoding)(s)
537 codecs.utf_16_decode('\x01', 'replace', True))
539 codecs.utf_16_decode('\x01', 'ignore', True))
542 self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True)
554 with codecs.open(test_support.TESTFN, 'U', encoding=self.encoding) as reader:
592 codecs.utf_16_le_decode(raw, 'strict', True)
633 codecs.utf_16_be_decode(raw, 'strict', True)
731 codecs.utf_7_decode(raw, 'strict', True)
778 self.assertRaises(UnicodeDecodeError, codecs.utf_16_ex_decode, "\xff", "strict", 0, True)
781 self.assertRaises(TypeError, codecs.utf_16_ex_decode)
788 codecs.readbuffer_encode(array.array("c", "spam")),
793 self.assertEqual(codecs.readbuffer_encode(""), ("", 0))
796 self.assertRaises(TypeError, codecs.readbuffer_encode)
797 self.assertRaises(TypeError, codecs.readbuffer_encode, 42)
802 self.assertEqual(codecs.charbuffer_encode("spam"), ("spam", 4))
805 self.assertEqual(codecs.charbuffer_encode(""), ("", 0))
808 self.assertRaises(TypeError, codecs.charbuffer_encode)
809 self.assertRaises(TypeError, codecs.charbuffer_encode, 42)
847 d = codecs.getincrementaldecoder("utf-8-sig")()
853 bytestring = codecs.BOM_UTF8 + "ABC\xC2\xA1\xE2\x88\x80XYZ"
855 reader = codecs.getreader("utf-8-sig")
877 reader = codecs.getreader("utf-8-sig")
897 self.assertEqual(codecs.escape_decode(""), ("", 0))
900 decode = codecs.escape_decode
907 decode = codecs.escape_decode
937 decode = codecs.escape_decode
950 f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8")
1119 codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
1120 decoder = codecs.getdecoder("unicode_internal")
1128 encoder = codecs.getencoder("unicode_internal")
1132 encoder = codecs.getencoder("string-escape")
1323 r = codecs.getreader("idna")(StringIO.StringIO("abc"))
1329 "".join(codecs.iterdecode("python.org", "idna")),
1333 "".join(codecs.iterdecode("python.org.", "idna")),
1337 "".join(codecs.iterdecode("xn--pythn-mua.org.", "idna")),
1341 "".join(codecs.iterdecode("xn--pythn-mua.org.", "idna")),
1345 decoder = codecs.getincrementaldecoder("idna")()
1359 "".join(codecs.iterencode(u"python.org", "idna")),
1363 "".join(codecs.iterencode(u"python.org.", "idna")),
1367 "".join(codecs.iterencode(u"pyth\xf6n.org.", "idna")),
1371 "".join(codecs.iterencode(u"pyth\xf6n.org.", "idna")),
1375 encoder = codecs.getincrementalencoder("idna")()
1388 self.assertEqual(codecs.decode('\xe4\xf6\xfc', 'latin-1'),
1390 self.assertRaises(TypeError, codecs.decode)
1391 self.assertEqual(codecs.decode('abc'), u'abc')
1392 self.assertRaises(UnicodeDecodeError, codecs.decode, '\xff', 'ascii')
1395 self.assertEqual(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'),
1397 self.assertRaises(TypeError, codecs.encode)
1398 self.assertRaises(LookupError, codecs.encode, "foo", "__spam__")
1399 self.assertEqual(codecs.encode(u'abc'), 'abc')
1400 self.assertRaises(UnicodeEncodeError, codecs.encode, u'\xffff', 'ascii')
1403 self.assertRaises(TypeError, codecs.register)
1404 self.assertRaises(TypeError, codecs.register, 42)
1407 self.assertRaises(TypeError, codecs.lookup)
1408 self.assertRaises(LookupError, codecs.lookup, "__spam__")
1409 self.assertRaises(LookupError, codecs.lookup, " ")
1412 self.assertRaises(TypeError, codecs.getencoder)
1413 self.assertRaises(LookupError, codecs.getencoder, "__spam__")
1416 self.assertRaises(TypeError, codecs.getdecoder)
1417 self.assertRaises(LookupError, codecs.getdecoder, "__spam__")
1420 self.assertRaises(TypeError, codecs.getreader)
1421 self.assertRaises(LookupError, codecs.getreader, "__spam__")
1424 self.assertRaises(TypeError, codecs.getwriter)
1425 self.assertRaises(LookupError, codecs.getwriter, "__spam__")
1437 c = codecs.lookup('ASCII')
1458 self.assertEqual(sorted(api), sorted(codecs.__all__))
1459 for api in codecs.__all__:
1460 getattr(codecs, api)
1465 self.reader = codecs.getreader('utf-8')
1476 ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8')
1480 ef = codecs.EncodedFile(f, 'utf-8', 'latin1')
1487 sin = codecs.encode("\x80", "base64_codec")
1488 reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
1494 sin = codecs.encode("\x80", "base64_codec")
1495 reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
1605 if hasattr(codecs, "mbcs_encode"):
1658 name = codecs.lookup(encoding).name
1664 (bytes, size) = codecs.getencoder(encoding)(s)
1666 (chars, size) = codecs.getdecoder(encoding)(bytes)
1672 writer = codecs.getwriter(encoding)(q)
1678 reader = codecs.getreader(encoding)(q)
1688 encoder = codecs.getincrementalencoder(encoding)()
1697 decoder = codecs.getincrementaldecoder(encoding)()
1706 result = u"".join(codecs.iterdecode(
1707 codecs.iterencode(s, encoding), encoding))
1711 result = u"".join(codecs.iterdecode(
1712 codecs.iterencode(u"", encoding), encoding))
1718 encoder = codecs.getincrementalencoder(encoding)("ignore")
1723 decoder = codecs.getincrementaldecoder(encoding)("ignore")
1776 reader = codecs.getreader(encoding)(StringIO.StringIO(s.encode(encoding)))
1785 decoder = codecs.getdecoder(encoding)
1792 encoder = codecs.getencoder(encoding)
1805 (bytes, size) = codecs.getencoder(encoding)(s)
1807 (chars, size) = codecs.getdecoder(encoding)(bytes)
1813 codecs.charmap_decode("\x00\x01\x02", "strict", u"abc"),
1818 codecs.charmap_decode, b"\x00\x01\x02", "strict", u"ab"
1822 codecs.charmap_decode, "\x00\x01\x02", "strict", u"ab\ufffe"
1826 codecs.charmap_decode("\x00\x01\x02", "replace", u"ab"),
1831 codecs.charmap_decode("\x00\x01\x02", "replace", u"ab\ufffe"),
1836 codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab"),
1841 codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab\ufffe"),
1847 codecs.charmap_decode(allbytes, "ignore", u""),
1853 codecs.charmap_decode("\x00\x01\x02", "strict",
1859 codecs.charmap_decode("\x00\x01\x02", "strict",
1865 codecs.charmap_decode("\x00\x01\x02", "strict",
1871 codecs.charmap_decode("\x00\x01\x02", "strict",
1877 codecs.charmap_decode, "\x00\x01\x02", "strict",
1882 codecs.charmap_decode, "\x00\x01\x02", "strict",
1888 codecs.charmap_decode, "\x00\x01\x02", "strict",
1893 codecs.charmap_decode("\x00\x01\x02", "replace",
1899 codecs.charmap_decode("\x00\x01\x02", "replace",
1906 codecs.charmap_decode("\x00\x01\x02", "replace",
1912 codecs.charmap_decode("\x00\x01\x02", "ignore",
1918 codecs.charmap_decode("\x00\x01\x02", "ignore",
1925 codecs.charmap_decode("\x00\x01\x02", "ignore",
1932 codecs.charmap_decode(allbytes, "ignore", {}),
1942 codecs.charmap_decode("\x00\x01\x02", "strict",
1949 codecs.charmap_decode("\x00\x01\x02", "strict",
1955 codecs.charmap_decode, "\x00\x01\x02", "strict",
1960 codecs.charmap_decode, "\x00\x01\x02", "strict",
1965 codecs.charmap_decode, "\x00\x01\x02", "strict",
1970 codecs.charmap_decode("\x00\x01\x02", "replace",
1976 codecs.charmap_decode("\x00\x01\x02", "replace",
1982 codecs.charmap_decode("\x00\x01\x02", "ignore",
1988 codecs.charmap_decode("\x00\x01\x02", "ignore",
1997 with codecs.EncodedFile(f, "latin-1", "utf-8") as ef:
2002 info = codecs.lookup("utf-8")
2003 with codecs.StreamReaderWriter(f, info.streamreader,
2010 self.assertEqual(codecs.unicode_escape_encode(u""), ("", 0))
2011 self.assertEqual(codecs.unicode_escape_decode(""), (u"", 0))
2014 encode = codecs.unicode_escape_encode
2020 decode = codecs.unicode_escape_decode
2026 encode = codecs.unicode_escape_encode
2041 decode = codecs.unicode_escape_decode
2070 decode = codecs.unicode_escape_decode
2088 self.assertEqual(codecs.raw_unicode_escape_encode(u""), ("", 0))
2089 self.assertEqual(codecs.raw_unicode_escape_decode(""), (u"", 0))
2092 encode = codecs.raw_unicode_escape_encode
2097 decode = codecs.raw_unicode_escape_decode
2102 encode = codecs.raw_unicode_escape_encode
2111 decode = codecs.raw_unicode_escape_decode
2120 decode = codecs.raw_unicode_escape_decode
2148 with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
2157 with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
2166 with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
2176 with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
2185 with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
2197 encoded = codecs.encode(b"space tab\teol \n", "quopri-codec")
2201 self.assertEqual(codecs.decode(unescaped, "quopri-codec"), unescaped)
2205 self.assertRaises(ValueError, codecs.decode, "", "uu-codec")