Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.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.059 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'literal': 0.09; 'subject:using': 0.09; 'valueerror:': 0.09; 'cc:addr:python-list': 0.11; 'bug': 0.12; '%d,': 0.16; '(pdb)': 0.16; '2:28': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage': 0.16; 'sorts': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'things.': 0.19; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; '15,': 0.26; 'compare': 0.26; 'extension': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'checking.': 0.31; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'two': 0.37; 'generating': 0.39; 'eventually': 0.60; 'then,': 0.60; 'wonderful': 0.60; "you're": 0.61; 'happen': 0.63; 'taking': 0.65; 'worth': 0.66; 'mar': 0.68; 'invalid': 0.68; 'completion': 0.78; '10:': 0.84; '2015': 0.84; 'absolutely': 0.87; 'crucial': 0.91; 'to:none': 0.92; '***': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=2tQkkqooGMUhcehwX6MgzMLRbYI61iu0r7eza9pHYBI=; b=nIWYWuZyc3CXP7Vly205wc2LeXjrbLQnv9IGxB7vBmNfrW8HaLPq8v4Zm/CTLCXw6h 2DsZTcDlWYdrkCgyeDbAltIYBnAKxcekHYXDz53QSP1ImKBt3q55VE2jcBHpWF9gByWr gQIFsSnz/7U6WCPL4VSroFTbL06pVqGO1+0sT3NX0ATbtM/9aYHEt4F0Z0ZHsyWukahR 9k7Qi3tJsM0lxTcQRPcQDKVTnGa8KWt4i4ctjMYLczoykOheRiEIjq1d710JUjsKKwsj wCGSm2bomeag278npFMplD/WWIXeCSWIWjtvq2iIbZyH2api0kSggJihYOWZahe3J0oQ 4r0w== MIME-Version: 1.0 X-Received: by 10.107.16.31 with SMTP id y31mr27966365ioi.53.1426348327532; Sat, 14 Mar 2015 08:52:07 -0700 (PDT) In-Reply-To: References: <877fuk71fz.fsf@nightsong.com> Date: Sun, 15 Mar 2015 02:52:07 +1100 Subject: Re: Odd ValueError using float From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1426348329 news.xs4all.nl 2882 [2001:888:2000:d::a6]:58756 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87423 On Sun, Mar 15, 2015 at 2:28 AM, emile wrote: > It ran almost to completion before generating the error again -- > > (Pdb) decval > '4' > (Pdb) type(decval) > > (Pdb) len(decval) > 1 > (Pdb) int(decval) > *** ValueError: invalid literal for int() with base 10: '41.700000000000003' > > So there's still something amiss. Compare these two lines' outputs: print("str %d, int %d" % (id(str), id(int))) print("str %d, int %d" % (id(type("")), id(type(0))) Any difference in id would indicate that the names have been shadowed - seems unlikely, but worth checking. And then, just to be absolutely sure: type(decval) is type("") There is another, and very nasty, possibility. If you're working with a C extension that has a refcount bug in it, all sorts of bizarre things can happen - crucial type objects getting garbage collected, objects getting disposed of and others taking their places, all kinds of weird and wonderful things. Normally that'll eventually cause a crash, but who knows... ChrisA