diff options
author | Armin Rigo <arigo@tunes.org> | 2011-07-31 18:37:45 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2011-07-31 18:37:45 +0200 |
commit | 0a49e78e0318cca1fb162e60a2e868267e66bd2f (patch) | |
tree | f3038f5efaac17295486933fa6e312de7509c621 | |
parent | MultibyteIncrementalDecoder. (diff) | |
download | pypy-0a49e78e0318cca1fb162e60a2e868267e66bd2f.tar.gz pypy-0a49e78e0318cca1fb162e60a2e868267e66bd2f.tar.bz2 pypy-0a49e78e0318cca1fb162e60a2e868267e66bd2f.zip |
Test and fix for reset().
-rw-r--r-- | pypy/module/_multibytecodec/interp_incremental.py | 4 | ||||
-rw-r--r-- | pypy/module/_multibytecodec/test/test_app_incremental.py | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/pypy/module/_multibytecodec/interp_incremental.py b/pypy/module/_multibytecodec/interp_incremental.py index f0635033c9..76c77e36f6 100644 --- a/pypy/module/_multibytecodec/interp_incremental.py +++ b/pypy/module/_multibytecodec/interp_incremental.py @@ -28,8 +28,8 @@ class MultibyteIncrementalDecoder(Wrappable): def _free(self): self.pending = None if self.decodebuf: - pypy_cjk_dec_free(self.decodebuf) - self.decodebuf = lltype.nullptr(DECODEBUF_P.TO) + c_codecs.pypy_cjk_dec_free(self.decodebuf) + self.decodebuf = lltype.nullptr(c_codecs.DECODEBUF_P.TO) def __del__(self): self._free() diff --git a/pypy/module/_multibytecodec/test/test_app_incremental.py b/pypy/module/_multibytecodec/test/test_app_incremental.py index 035d884eba..72cb9da2c2 100644 --- a/pypy/module/_multibytecodec/test/test_app_incremental.py +++ b/pypy/module/_multibytecodec/test/test_app_incremental.py @@ -49,3 +49,17 @@ class AppTestClasses: assert r == u'' raises(UnicodeDecodeError, d.decode, "~", True) raises(UnicodeDecodeError, d.decode, "~{a", True) + + def test_decode_hz_reset(self): + d = self.IncrementalHzDecoder() + r = d.decode("ab") + assert r == u'ab' + r = d.decode("~{") + assert r == u'' + r = d.decode("ab") + assert r == u'\u5f95' + r = d.decode("ab") + assert r == u'\u5f95' + d.reset() + r = d.decode("ab") + assert r == u'ab' |