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


Groups > comp.lang.python > #40831

Re: Unhelpful traceback

References <kh9c95$t68$1@dont-email.me> <mailman.3016.1362661824.2939.python-list@python.org> <khan0m$ud6$1@dont-email.me> <khb3c0$d17$1@dont-email.me>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-03-07 15:32 -0700
Subject Re: Unhelpful traceback
Newsgroups comp.lang.python
Message-ID <mailman.3059.1362695621.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Mar 7, 2013 at 3:13 PM, John Nagle <nagle@animats.com> wrote:
> On 3/7/2013 10:42 AM, John Nagle wrote:
>> On 3/7/2013 5:10 AM, Dave Angel wrote:
>>> On 03/07/2013 01:33 AM, John Nagle wrote:
>>>> Here's a traceback that's not helping:
>>>>
>>>
>>> A bit more context would be helpful.  Starting with Python version.
>>
>>     Sorry, Python 2.7.
>
> The trouble comes from here:
>
>         decoder = codecs.getreader('utf-8')          # UTF-8 reader
>         with decoder(infdraw,errors="replace") as infd :
>
> It's not the CSV module that's blowing up.  If I just feed the
> raw unconverted bytes from the ZIP module into the CSV module,
> the CSV module runs without complaint.
>
> I've tried 'utf-8', 'ascii', and 'windows-1252' as codecs.
> They all blow up. 'errors="replace"' doesn't help.

I believe that the csv module is expecting string data, not unicode.
Since it receives unicode as a result of your decoder step, it tries
to convert it to a string using str(), which implicitly tries to
encode the data using the ascii codec, hence the error that you're
seeing.

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


Thread

Unhelpful traceback John Nagle <nagle@animats.com> - 2013-03-06 22:33 -0800
  Re: Unhelpful traceback Andrew Berg <bahamutzero8825@gmail.com> - 2013-03-07 00:57 -0600
  Re: Unhelpful traceback Chris Rebert <clp2@rebertia.com> - 2013-03-06 23:04 -0800
  Re: Unhelpful traceback Dave Angel <davea@davea.name> - 2013-03-07 08:10 -0500
    Re: Unhelpful traceback John Nagle <nagle@animats.com> - 2013-03-07 10:42 -0800
      Re: Unhelpful traceback John Nagle <nagle@animats.com> - 2013-03-07 14:13 -0800
        Re: Unhelpful traceback Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-07 15:32 -0700
    Re: Unhelpful traceback John Nagle <nagle@animats.com> - 2013-03-07 13:23 -0800
      Re: Unhelpful traceback Dave Angel <davea@davea.name> - 2013-03-07 19:23 -0500

csiph-web