Skip to content

problematic String.serialize/deserialize behaviour for bytes in python 3 #251

@novocaine

Description

@novocaine

If colander.String() is passed bytes data on python 3 and self.encoding is None, it does str() on the bytes object.

This is almost always undesirable on python 3 as, unlike python 2, there is no implicit encoding peformed and instead you get a 'b' and some quotes whacked in:

>>> str(b'test')
"b'test'"

Note that if the interpreter is running with -b or -bb this is a warning or an error respectively.

In my view, colander should raise an Exception in this case under python 3 as there is no sane way to make it into an actual string in the absence of an encoding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions