Python3.3 str() bug?

Ian Kelly ian.g.kelly at
Fri Nov 9 18:25:43 CET 2012

On Fri, Nov 9, 2012 at 2:18 AM, Helmut Jarausch
<jarausch at> wrote:
> Hi,
> probably I'm missing something.
> Using   str(Arg) works just fine if  Arg is a list.
> But
>   str([],encoding='latin-1')
> gives the error
> TypeError: coercing to str: need bytes, bytearray or buffer-like object,
>            list found
> If this isn't a bug how can I use str(Arg,encoding='latin-1') in general.
> Do I need to flatten any data structure which is normally excepted by str() ?

In general, the __str__ implementations of complex data structures
will call repr() on their components, not str().  repr() normally does
not do any decoding in the first place and does not take an encoding
argument, so even if str([]) accepted an encoding, it wouldn't be
useful for anything.

More information about the Python-list mailing list