[pypy-svn] r61100 - in pypy/trunk/pypy/module/_codecs: . test
fijal at codespeak.net
fijal at codespeak.net
Mon Jan 19 10:56:06 CET 2009
Author: fijal
Date: Mon Jan 19 10:56:04 2009
New Revision: 61100
Modified:
pypy/trunk/pypy/module/_codecs/app_codecs.py
pypy/trunk/pypy/module/_codecs/test/test_codecs.py
Log:
oops
Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/app_codecs.py (original)
+++ pypy/trunk/pypy/module/_codecs/app_codecs.py Mon Jan 19 10:56:04 2009
@@ -88,7 +88,7 @@
def charmap_encode(obj, errors='strict', mapping='latin-1'):
"""None
"""
- res = PyUnicode_EncodeCharmap(obj, len(obj), mapping, errors)
+ res = PyUnicode_EncodeCharmap(obj, mapping, errors)
res = ''.join(res)
return res, len(res)
@@ -821,7 +821,7 @@
else:
raise TypeError("character mapping must return integer, None or str")
-def PyUnicode_EncodeCharmap(p, size, mapping='latin-1', errors='strict'):
+def PyUnicode_EncodeCharmap(p, mapping='latin-1', errors='strict'):
## /* the following variable is used for caching string comparisons
## * -1=not initialized, 0=unknown, 1=strict, 2=replace,
@@ -831,6 +831,7 @@
if mapping == 'latin-1':
import _codecs
return _codecs.latin_1_encode(p, errors)[0]
+ size = len(p)
if (size == 0):
return ''
inpos = 0
@@ -839,7 +840,7 @@
#/* try to encode it */
try:
x = charmapencode_output(ord(p[inpos]), mapping)
- res += x[0]
+ res += x
except KeyError:
x = unicode_call_errorhandler(errors, "charmap",
"character maps to <undefined>", p, inpos, inpos+1, False)
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 Mon Jan 19 10:56:04 2009
@@ -500,3 +500,4 @@
def test_charmap_encode(self):
from pypy.module._codecs.app_codecs import charmap_encode
assert charmap_encode('xxx') == ('xxx', 3)
+ assert charmap_encode('xxx', 'strict', {ord('x'): 'XX'}) == ('XXXXXX', 6)
More information about the Pypy-commit
mailing list