bpo-33578: Fix getstate/setstate for CJK decoder (GH-10290)

Previous version was casting to Py_ssize_t incorrectly
and exhibited unexpected behavior on big-endian systems.
This commit is contained in:
Christopher Thorne 2018-11-02 03:29:40 +00:00 committed by INADA Naoki
parent 318ab63c01
commit 488c0a6cdf
2 changed files with 26 additions and 5 deletions

View file

@ -271,6 +271,10 @@ class Test_IncrementalDecoder(unittest.TestCase):
pending4, _ = decoder.getstate()
self.assertEqual(pending4, b'')
# Ensure state values are preserved correctly
decoder.setstate((b'abc', 123456789))
self.assertEqual(decoder.getstate(), (b'abc', 123456789))
def test_setstate_validates_input(self):
decoder = codecs.getincrementaldecoder('euc_jp')()
self.assertRaises(TypeError, decoder.setstate, 123)