Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'raises': 0.07; 'args,': 0.09; 'bug?': 0.09; 'raised.': 0.09; 'reports.': 0.09; 'tuple': 0.09; 'valueerror:': 0.09; 'subject:error': 0.09; '"...': 0.16; '"expected': 0.16; '14",': 0.16; 'iterable,': 0.16; 'rhs': 0.16; 'roy': 0.16; 'saying,': 0.16; 'unpack': 0.16; 'unpacking': 0.16; "\xa0it's": 0.16; 'wrote:': 0.18; 'dec': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'items.': 0.23; 'function': 0.27; 'variable': 0.28; 'url:mailman': 0.28; 'lists': 0.28; 'message-id:@mail.gmail.com': 0.28; 'explicit': 0.29; 'error': 0.29; 'pm,': 0.29; 'values': 0.32; 'returning': 0.32; 'thu,': 0.32; 'url:listinfo': 0.32; 'instead': 0.33; 'to:addr :python-list': 0.34; 'probably': 0.34; 'too': 0.34; 'things': 0.34; 'supposed': 0.35; 'url:python': 0.36; 'but': 0.37; 'list,': 0.37; 'received:google.com': 0.37; 'could': 0.37; 'received:209.85': 0.38; 'possible.': 0.39; 'url:org': 0.39; 'should': 0.39; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'more': 0.61; '2011': 0.61; 'happen': 0.61; 'stop': 0.63; 'subject:day': 0.68; 'observed': 0.84 MIME-Version: 1.0 In-Reply-To: <3164448.1087.1323369765528.JavaMail.geo-discussion-forums@yqcm37> References: <18647617.2258.1323358966076.JavaMail.geo-discussion-forums@yqf20> <3164448.1087.1323369765528.JavaMail.geo-discussion-forums@yqcm37> Date: Thu, 8 Dec 2011 13:57:28 -0500 Subject: Re: Misleading error message of the day From: Benjamin Kaplan To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323370719 news.xs4all.nl 6946 [2001:888:2000:d::a6]:37919 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16862 On Thu, Dec 8, 2011 at 1:42 PM, Roy Smith wrote: > (some, > =A0very, > =A0long, > =A0list, > =A0of, > =A0variable, > =A0names, > =A0to, > =A0get, > =A0the, > =A0stuff, > =A0unpacked, > =A0into) =3D function_that_should_return_a_14_tuple() > > raises > > ValueError: too many values to unpack > > Quick, what's the bug? =A0Did I forget a variable on the LHS, or is my fu= nction returning more things than it should? =A0I know it's supposed to be = 14, but I don't know which side is wrong. =A0Had it said "... expected 13, = got 14", I would know immediately. > If the RHS was a tuple or a list, yes you could know immediately. But unpacking works with any iterable, so it probably doesn't special-case lists and tuples. Iterables don't have a size- they just keep going until StopIteration is raised. So in EVERY SINGLE CASE, you would get "expected n args, got n+1" even if the iterable would return 24 items instead of 14, or would never stop returning items. > Error messages should be as explicit as possible. =A0It's just like bug r= eports. =A0The basic mantra of a bug report is: > > 1) This is what I did > > 2) This is what I expected to happen > > 3) This is what I observed happen > > 4) This is how what I observed differed from what I expected > > Saying, "expected X, got Y" is more explicit than "got too many" > > > -- > http://mail.python.org/mailman/listinfo/python-list