atsuo ishimoto added the comment:
Codecs would hardly ever raises exception here.
Usually, exception raised here would be a MemoryError. The unicode
string we are trying to encode is just decoded by same codec. If codec
raises exception other than MemoryError, the codec will likely have problem.
I attached a script to print exception raised by codec. I wrote a "buggy"
encoder, which never return string but raises an exception.
_____________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1031213>
_____________________________________
import codecs
def encoder(s, errors="strict"):
raise RuntimeError("dummy error")
def decoder(s, errors="strict"):
return unicode(s, 'ascii', errors), len(s)
def dmy_search(encoding):
if encoding == "dmyencoding":
return (encoder, decoder, codecs.StreamWriter, codecs.StreamReader)
def test():
codecs.register(dmy_search)
src = """#! -*- coding: dmyencoding -*-\n
print 'hello
"""
compile(src, "", "exec")
test()
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com