Author: Armin Rigo <[email protected]>
Branch:
Changeset: r44710:c90872144bec
Date: 2011-06-05 11:11 +0200
http://bitbucket.org/pypy/pypy/changeset/c90872144bec/
Log: For now, custom error handlers are not supported.
diff --git a/pypy/module/_multibytecodec/c_codecs.py
b/pypy/module/_multibytecodec/c_codecs.py
--- a/pypy/module/_multibytecodec/c_codecs.py
+++ b/pypy/module/_multibytecodec/c_codecs.py
@@ -152,8 +152,9 @@
return # continue decoding
start = pypy_cjk_dec_inbuf_consumed(decodebuf)
end = start + esize
- if 1: # errors == ERROR_STRICT:
- raise EncodeDecodeError(start, end, reason)
+ if errors != "strict":
+ reason = "not implemented: custom error handlers" # XXX implement me
+ raise EncodeDecodeError(start, end, reason)
# ____________________________________________________________
# Encoding
diff --git a/pypy/module/_multibytecodec/test/test_c_codecs.py
b/pypy/module/_multibytecodec/test/test_c_codecs.py
--- a/pypy/module/_multibytecodec/test/test_c_codecs.py
+++ b/pypy/module/_multibytecodec/test/test_c_codecs.py
@@ -46,6 +46,14 @@
u = decode(c, 'def~{}abc', 'replace')
assert u == u'def\ufffd\u5fcf'
+def test_decode_hz_foobar():
+ # not implemented yet: custom error handlers
+ c = getcodec("hz")
+ e = py.test.raises(EncodeDecodeError, decode, c, "~{xyz}", "foobar").value
+ assert e.start == 2
+ assert e.end == 4
+ assert e.reason == "not implemented: custom error handlers"
+
def test_encode_hz():
c = getcodec("hz")
s = encode(c, u'foobar')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit