[issue4874] decoding functions in _codecs module accept str arguments

Antoine Pitrou report at bugs.python.org
Thu Jan 22 12:05:11 CET 2009


Antoine Pitrou <pitrou at free.fr> added the comment:

"Fixing" multibytecodec.c produces a TypeError in the following test:

    def test_errorcallback_longindex(self):
        dec = codecs.getdecoder('euc-kr')
        myreplace  = lambda exc: ('', sys.maxsize+1)
        codecs.register_error('test.cjktest', myreplace)
        self.assertRaises(IndexError, dec,
                          'apple\x92ham\x93spam', 'test.cjktest')

TypeError: decode() argument 1 must be bytes or buffer, not str

Since the test is meant to test recovery from a misbehaving callback, I
guess the type of the input string is not really important and can be
changed to a bytes string instead. What do you think?

(in any case, here is a patch)

Added file: http://bugs.python.org/file12831/mbdecode-unicode.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4874>
_______________________________________


More information about the Python-bugs-list mailing list