Ma Lin added the comment: I found another bug in hz codec. hz encoding uses 7-bit ASCII to represent Chinese characters, it was popular in USENET networks in the late 1980s and early 1990s.
I will do more check and fix them together, then I will invite you to review the patch. u = 'hi~python' b = u.encode('hz') # bug in this step, the right sequence should be b"hi~~python" print(b) # the output is b"hi~python" u = b.decode('hz') # so can't decode, UnicodeDecodeError raised print(u) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24117> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com