[pypy-issue] Issue #2007: pypy2: `codecs.charmap_decode` doesn't work on bytearrays (pypy/pypy)

Robert Speer issues-reply at bitbucket.org
Tue Mar 24 17:56:27 CET 2015


New issue 2007: pypy2: `codecs.charmap_decode` doesn't work on bytearrays
https://bitbucket.org/pypy/pypy/issue/2007/pypy2-codecscharmap_decode-doesnt-work-on

Robert Speer:

Unlike the CPython standard library, pypy2 2.5.0 does not allow `codecs.charmap_decode` to be used on bytearrays. This means that bytearrays cannot be decoded with some codecs.

CPython 2.7.6:

    >>> bytearray('test').decode('cp1252')
    u'test'

PyPy 2.5.0:


    >>>> bytearray('test').decode('cp1252')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/rspeer/src/pypy-2.5.0-linux64/lib-python/2.7/encodings/cp1252.py", line 15, in decode
        return codecs.charmap_decode(input,errors,decoding_table)
    TypeError: expected string, got bytearray object

This causes the Unicode-fixing library [ftfy](https://github.com/LuminosoInsight/python-ftfy) to fail to import on PyPy2.




More information about the pypy-issue mailing list