[pypy-svn] r61281 - in pypy/trunk/pypy/module/_codecs: . test
fijal at codespeak.net
fijal at codespeak.net
Fri Jan 23 20:23:38 CET 2009
Author: fijal
Date: Fri Jan 23 20:23:36 2009
New Revision: 61281
Modified:
pypy/trunk/pypy/module/_codecs/interp_codecs.py
pypy/trunk/pypy/module/_codecs/test/test_codecs.py
Log:
a test and a fix
Modified: pypy/trunk/pypy/module/_codecs/interp_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/interp_codecs.py (original)
+++ pypy/trunk/pypy/module/_codecs/interp_codecs.py Fri Jan 23 20:23:36 2009
@@ -210,7 +210,7 @@
state = space.fromcache(CodecState)
func = getattr(runicode, rname)
result = func(uni, len(uni), errors, state.encode_error_handler)
- return space.newtuple([space.wrap(result), space.wrap(len(result))])
+ return space.newtuple([space.wrap(result), space.wrap(len(uni))])
wrap_encoder.unwrap_spec = [ObjSpace, unicode, str]
globals()[name] = wrap_encoder
Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original)
+++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Fri Jan 23 20:23:36 2009
@@ -506,6 +506,12 @@
assert exc.start == 0
assert exc.end == 3
+ def test_utf_16_encode_decode(self):
+ import codecs
+ x = u'123abc'
+ assert codecs.getencoder('utf-16')(x) == ('\xff\xfe1\x002\x003\x00a\x00b\x00c\x00', 6)
+ assert codecs.getdecoder('utf-16')('\xff\xfe1\x002\x003\x00a\x00b\x00c\x00') == (x, 14)
+
class TestDirect:
def test_charmap_encode(self):
from pypy.module._codecs.app_codecs import charmap_encode
More information about the Pypy-commit
mailing list