Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'context': 0.05; 'ascii': 0.07; 'utf-8': 0.07; 'python': 0.09; 'encode': 0.09; 'receives': 0.13; "'ascii',": 0.16; "'utf-8',": 0.16; 'csv': 0.16; 'unicode.': 0.16; 'string': 0.17; 'wrote:': 0.17; 'bytes': 0.17; 'module,': 0.17; 'thu,': 0.17; 'tries': 0.17; 'unicode': 0.17; 'version.': 0.17; '>>>': 0.18; 'module': 0.19; 'bit': 0.21; 'sorry,': 0.22; 'help.': 0.22; 'runs': 0.22; "i've": 0.23; 'tried': 0.25; 'header :In-Reply-To:1': 0.25; 'am,': 0.27; 'raw': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'trouble': 0.28; '>>>>': 0.29; 'helpful.': 0.29; 'implicitly': 0.29; 'convert': 0.29; "skip:' 10": 0.30; 'error': 0.30; 'up.': 0.31; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'data,': 0.35; 'feed': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'your': 0.60; 'john': 0.60; 'here:': 0.62; 'more': 0.63; 'believe': 0.69; '2.7.': 0.84; '2013': 0.84; 'blow': 0.84; 'blowing': 0.84; 'step,': 0.84; 'to:name:python': 0.84; 'angel': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=JKuaS6Cveyejd6Fs6BJRX92PB5/d0IfN92vbV2FT34U=; b=GXo+WXGJVNb3vBFGJh2HDd+b7e5QyweAZ4Dao1O1z6X53ws5w+sPKZaaCmzq73CKNV Pf0dpFfPovKjClUYPsz/7gyXVQN4kVpH3lguV/9gedz6AAJYSlrX7Fh35cxjk8Ho+sI3 MhpZRun0py4+2BFAT9iqd9IMPhlno71wXCxO09yHQfa/O1/RdKh5ThvRvlmpgXsP+S81 cXupU8xD9km2nI+qsN6ShBhmouNA0Jxsu6mWEhyAhKnWeuWYqMOj08M3rHVcKiGkPEmz lLXskGslkZquGwNjtAeftNZJo0ZPWMzVgJ/iF72GPeEcGFF+D1jlCJHeYWIRQ+cysb/P gLYQ== X-Received: by 10.52.22.194 with SMTP id g2mr12078022vdf.91.1362695613339; Thu, 07 Mar 2013 14:33:33 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Thu, 7 Mar 2013 15:32:53 -0700 Subject: Re: Unhelpful traceback To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362695621 news.xs4all.nl 6857 [2001:888:2000:d::a6]:56910 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40831 On Thu, Mar 7, 2013 at 3:13 PM, John Nagle 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.