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


Groups > comp.lang.python > #33039

Re: Python3.3 str() bug?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:bug': 0.05; 'arg': 0.09; 'argument,': 0.09; 'bytearray': 0.09; 'bytes,': 0.09; 'components,': 0.09; 'typeerror:': 0.09; 'bug': 0.10; "wouldn't": 0.11; 'encoding': 0.15; 'buffer-like': 0.16; 'decoding': 0.16; 'general.': 0.16; 'repr()': 0.16; 'str()': 0.16; 'wrote:': 0.17; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'object,': 0.27; 'structures': 0.27; 'message-id:@mail.gmail.com': 0.27; 'fine': 0.28; 'probably': 0.29; "i'm": 0.29; 'fri,': 0.30; 'normally': 0.30; 'received:209.85.215.46': 0.30; 'error': 0.30; 'structure': 0.32; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'nov': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'list.': 0.35; 'but': 0.36; 'useful': 0.36; 'does': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=1BlHK7PGbBKEnPAoQOeaaJ5i+VcRwmEivlRSN4sVc3E=; b=VePLNChMMqnbaPrPEmtuvyP8HoQT2pStIsN+yeRKNNEp4BlinrJaV+tWRNkom2fNS6 IuO/lPS5Z/bIf6F/LdhCXsHV6hyQf8Xt+uIzpQKNdB8Vw7AUmAGnp2Rcv5niNZx4txfD 0g6IkSzMwjNLggIyBOsNrtIKQTX1MNBoBNkFNC3KrMRKmPwj4phBZKF2NUmDUbX6Pqw+ W4QLP5I7KNnJnBlojN+LObU9i7wbQWKWSqzTjww2fCn86ehtSqpCRHHjI7z3apegz9Ah D9bPCbZcsij84uzOslmVbE8eOFyxZV+1z9EgpINjat6EwOOVhlRXZQRvMiGgZtZ057wA TiIw==
MIME-Version 1.0
In-Reply-To <ag402kFkb9hU1@mid.dfncis.de>
References <ag402kFkb9hU1@mid.dfncis.de>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 9 Nov 2012 10:25:43 -0700
Subject Re: Python3.3 str() bug?
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3504.1352481975.27098.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352481975 news.xs4all.nl 6977 [2001:888:2000:d::a6]:54057
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33039

Show key headers only | 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