Lines Matching refs:codecs
1 import codecs
98 codecs.register_error(
126 codecs.register_error(
181 codecs.register_error("test.relaxedutf8", relaxedutf8)
201 self.assertEqual(codecs.charmap_encode(sin, "strict", charmap)[0], sout)
204 self.assertRaises(UnicodeError, codecs.charmap_encode, sin, "strict", charmap)
209 self.assertEqual(codecs.charmap_encode(sin, "replace", charmap)[0], sout)
212 self.assertRaises(TypeError, codecs.charmap_encode, sin, "replace", charmap)
243 codecs.register_error("test.hui", handler_unicodeinternal)
261 codecs.register_error("test.handler1", handler1)
269 codecs.register_error("test.handler2", handler2)
293 codecs.charmap_decode(b"abc", "test.handler1", {ord("a"): "z"})[0],
314 codecs.register_error("test." + err, codecs.lookup_error(err))
426 codecs.strict_errors,
432 codecs.strict_errors,
439 codecs.strict_errors,
444 codecs.strict_errors,
449 codecs.strict_errors,
457 codecs.ignore_errors,
463 codecs.ignore_errors,
468 codecs.ignore_errors(
473 codecs.ignore_errors(
478 codecs.ignore_errors(
487 codecs.replace_errors,
493 codecs.replace_errors,
498 codecs.replace_errors,
503 codecs.replace_errors,
508 codecs.replace_errors(
513 codecs.replace_errors(
518 codecs.replace_errors(
527 codecs.xmlcharrefreplace_errors,
533 codecs.xmlcharrefreplace_errors,
539 codecs.xmlcharrefreplace_errors,
544 codecs.xmlcharrefreplace_errors,
553 codecs.xmlcharrefreplace_errors(
564 codecs.backslashreplace_errors,
570 codecs.backslashreplace_errors,
592 codecs.backslashreplace_errors(
598 codecs.backslashreplace_errors(
612 codecs.backslashreplace_errors(
622 codecs.namereplace_errors,
628 codecs.namereplace_errors,
634 codecs.namereplace_errors,
639 codecs.namereplace_errors,
658 codecs.namereplace_errors(
665 surrogateescape_errors = codecs.lookup_error('surrogateescape')
709 surrogatepass_errors = codecs.lookup_error('surrogatepass')
785 codecs.register_error("test.badhandler", lambda x: res)
809 self.assertEqual(codecs.strict_errors, codecs.lookup_error("strict"))
810 self.assertEqual(codecs.ignore_errors, codecs.lookup_error("ignore"))
811 self.assertEqual(codecs.strict_errors, codecs.lookup_error("strict"))
813 codecs.xmlcharrefreplace_errors,
814 codecs.lookup_error("xmlcharrefreplace")
817 codecs.backslashreplace_errors,
818 codecs.lookup_error("backslashreplace")
821 codecs.namereplace_errors,
822 codecs.lookup_error("namereplace")
831 codecs.register_error("test.unencreplhandler", unencrepl)
844 self.assertRaises(TypeError, codecs.register_error, 42)
845 self.assertRaises(TypeError, codecs.register_error, "test.dummy", 42)
850 self.assertRaises(TypeError, codecs.lookup_error)
855 self.assertRaises(LookupError, codecs.lookup_error, "test.unknown")
864 codecs.register_error("test.xmlcharrefreplace", codecs.xmlcharrefreplace_errors)
877 codecs.register_error("test.baddecodereturn1", baddecodereturn1)
887 codecs.register_error("test.baddecodereturn2", baddecodereturn2)
891 codecs.register_error("test.posreturn", handler.handle)
924 self.assertRaises(UnicodeError, codecs.charmap_decode, b"\xff", "strict", {0xff: None})
925 self.assertRaises(ValueError, codecs.charmap_decode, b"\xff", "strict", D())
926 … self.assertRaises(TypeError, codecs.charmap_decode, b"\xff", "strict", {0xff: sys.maxunicode+1})
936 codecs.register_error("test.badencodereturn1", badencodereturn1)
941 codecs.register_error("test.badencodereturn2", badencodereturn2)
945 codecs.register_error("test.posreturn", handler.handle)
978 self.assertRaises(UnicodeError, codecs.charmap_encode, "\xff", err, {0xff: None})
979 self.assertRaises(ValueError, codecs.charmap_encode, "\xff", err, D())
980 self.assertRaises(TypeError, codecs.charmap_encode, "\xff", err, {0xff: 300})
1025 codecs.register_error("test.replacing", replacing)
1039 codecs.register_error("test.mutating", mutating)
1057 codecs.register_error(
1087 codecs.register_error("test.replace_with_long", replace_with_long)
1101 codecs.strict_errors,
1102 codecs.ignore_errors,
1103 codecs.replace_errors,
1104 codecs.backslashreplace_errors,
1105 codecs.namereplace_errors,
1106 codecs.xmlcharrefreplace_errors,
1107 codecs.lookup_error('surrogateescape'),
1108 codecs.lookup_error('surrogatepass'),