[pypy-commit] pypy default: Pass the "errors" argument down from app-level.
Armin Rigo
noreply at buildbot.pypy.org
Sun Jun 5 11:14:34 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r44708:a5cc211dc30a
Date: 2011-06-05 10:55 +0200
http://bitbucket.org/pypy/pypy/changeset/a5cc211dc30a/
Log: Pass the "errors" argument down from app-level.
diff --git a/pypy/module/_multibytecodec/interp_multibytecodec.py b/pypy/module/_multibytecodec/interp_multibytecodec.py
--- a/pypy/module/_multibytecodec/interp_multibytecodec.py
+++ b/pypy/module/_multibytecodec/interp_multibytecodec.py
@@ -13,13 +13,11 @@
@unwrap_spec(input=str, errors="str_or_None")
def decode(self, space, input, errors=None):
- if errors is not None and errors != 'strict':
- raise OperationError(space.w_NotImplementedError, # XXX
- space.wrap("errors='%s' in _multibytecodec"
- % errors))
+ if errors is None:
+ errors = 'strict'
#
try:
- output = c_codecs.decode(self.codec, input)
+ output = c_codecs.decode(self.codec, input, errors)
except c_codecs.EncodeDecodeError, e:
raise OperationError(
space.w_UnicodeDecodeError,
diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py b/pypy/module/_multibytecodec/test/test_app_codecs.py
--- a/pypy/module/_multibytecodec/test/test_app_codecs.py
+++ b/pypy/module/_multibytecodec/test/test_app_codecs.py
@@ -36,6 +36,14 @@
e = raises(UnicodeDecodeError, codec.decode, "~{xyz}").value
assert e.args == ('hz', '~{xyz}', 2, 4, 'illegal multibyte sequence')
+ def test_decode_hz_ignore(self):
+ import _codecs_cn
+ codec = _codecs_cn.getcodec("hz")
+ r = codec.decode("def~{}abc", errors='ignore')
+ assert r == (u'def\u5fcf', 9)
+ r = codec.decode("def~{}abc", 'ignore')
+ assert r == (u'def\u5fcf', 9)
+
def test_encode_hz(self):
import _codecs_cn
codec = _codecs_cn.getcodec("hz")
More information about the pypy-commit
mailing list