Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33039

Re: Python3.3 str() bug?

References <ag402kFkb9hU1@mid.dfncis.de>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-11-09 10:25 -0700
Subject Re: Python3.3 str() bug?
Newsgroups comp.lang.python
Message-ID <mailman.3504.1352481975.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Nov 9, 2012 at 2:18 AM, Helmut Jarausch
<jarausch@igpm.rwth-aachen.de> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Python3.3  str() bug? Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2012-11-09 09:18 +0000
  Re: Python3.3  str() bug? Stefan Behnel <stefan_ml@behnel.de> - 2012-11-09 10:37 +0100
    Re: Python3.3  str() bug? Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2012-11-09 11:08 +0000
      Re: Python3.3 str() bug? Chris Angelico <rosuav@gmail.com> - 2012-11-09 23:22 +1100
        Re: Python3.3 str() bug? Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2012-11-09 13:13 +0000
          Re: Python3.3 str() bug? Stefan Behnel <stefan_ml@behnel.de> - 2012-11-09 18:07 +0100
          Re: Python3.3 str() bug? Terry Reedy <tjreedy@udel.edu> - 2012-11-09 18:35 -0500
      RE: Python3.3 str() bug? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-09 17:47 +0000
      Re: Python3.3 str() bug? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-10 16:45 +0000
  Re: Python3.3 str() bug? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 10:25 -0700

csiph-web