]> granicus.if.org Git - python/commit
bpo-33578: Add getstate/setstate for CJK codec (GH-6984)
authorChristopher Thorne <libcthorne@users.noreply.github.com>
Thu, 1 Nov 2018 10:48:49 +0000 (10:48 +0000)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 1 Nov 2018 10:48:49 +0000 (03:48 -0700)
commitac22f6aa989f18c33c12615af1c66c73cf75d5e7
treebb21f3018f9b5e4b40ede33ce78bba1b13980f86
parent4b5e62dbb22a3593e0db266c12f805b727a42b00
bpo-33578: Add getstate/setstate for CJK codec (GH-6984)

This implements getstate and setstate for the cjkcodecs multibyte incremental encoders/decoders, primarily to fix issues with seek/tell.

The encoder getstate/setstate is slightly tricky as the "state" is pending bytes + MultibyteCodec_State but only an integer can be returned. The approach I've taken is to encode this data into a long, similar to how .tell() encodes a "cookie_type" as a long.

https://bugs.python.org/issue33578
Lib/test/test_io.py
Lib/test/test_multibytecodec.py
Misc/ACKS
Misc/NEWS.d/next/Library/2018-06-08-23-55-34.bpo-33578.7oSsjG.rst [new file with mode: 0644]
Modules/cjkcodecs/_codecs_cn.c
Modules/cjkcodecs/clinic/multibytecodec.c.h
Modules/cjkcodecs/multibytecodec.c
Modules/cjkcodecs/multibytecodec.h