Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'bug': 0.12; '%d,': 0.16; '(pdb)': 0.16; '2:28': 0.16; 'garbage': 0.16; 'pdb': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sorts': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'module': 0.19; 'normally': 0.19; 'things.': 0.19; 'seems': 0.21; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; '15,': 0.26; 'compare': 0.26; 'extension': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'getting': 0.31; 'checking.': 0.31; 'os,': 0.31; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'two': 0.37; 'to:addr:python-list': 0.38; 'generating': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'eventually': 0.60; 'then,': 0.60; 'wonderful': 0.60; 'break': 0.61; "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; 'condition.': 0.84; 'received:pacbell.net': 0.84; 'absolutely': 0.87; 'crucial': 0.91; '***': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: emile Subject: Re: Odd ValueError using float Date: Sat, 14 Mar 2015 10:17:57 -0700 References: <877fuk71fz.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-69-226-129-65.dsl.pltn13.pacbell.net User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: 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: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1426353497 news.xs4all.nl 2844 [2001:888:2000:d::a6]:34729 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87435 On 03/14/2015 08:52 AM, Chris Angelico wrote: > 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))) > (Pdb) print("str %d, int %d" % (id(str), id(int))) str 505366496, int 505399904 (Pdb) print("str %d, int %d" % (id(type("")), id(type(0)))) str 505366496, int 505399904 > 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("") (Pdb) type(decval) is type("") True > 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... Here're the imports: import os, time, re, shutil, subprocess from fenx.BBxXlate.bbxfile import BBxFile # a pure python module from fenx import RealPyOdbc2 and of course, pdb when I break for the error condition. Emile