New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decoding functions in _codecs module accept str arguments #49124
Comments
The following function calls should raise a TypeError instead. Encoding >>> import codecs
>>> codecs.utf_8_decode('aa')
('aa', 2)
>>> codecs.utf_8_decode('éé')
('éé', 4)
>>> codecs.latin_1_decode('éé')
('éé', 4) |
Patch replacing "s*" parsing format by "y*" for:
Using run_tests.sh, all tests are ok (with 19 skipped tests). I guess Note: codecs documentation was already correct: .. method:: Codec.decode(input[, errors]) |
On 2009-01-08 01:59, STINNER Victor wrote:
These are fine.
These changes are in line with their C API codec interfaces as well, I'll probably open a new item for this.
The mbcs codec is only available on Windows. All others are tested by test_codecs.py. Which ones are skipped in your case ?
That's not entirely correct: codecs are allowed to accept any I guess I have to review those doc changes... |
The patch is probably fine, but it would be nice to add some unit tests |
On 2009-01-13 14:14, Antoine Pitrou wrote:
+1 from my side. Thanks for the patch, Viktor. |
New patch:
|
Committed in r68855, r68856. Thanks! |
IMO, Modules/cjkcodecs/multibytecodec.c should be changed as well. |
Right, I hadn't thought of that. |
"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 (in any case, here is a patch) |
The patch looks good. |
Committed in r68857, r68858. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: