Unhelpful traceback

Ian Kelly ian.g.kelly at gmail.com
Thu Mar 7 23:32:53 CET 2013

On Thu, Mar 7, 2013 at 3:13 PM, John Nagle <nagle at 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

More information about the Python-list mailing list