Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87423

Re: Odd ValueError using float

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 <rosuav@gmail.com>
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 <me1k2i$ljt$1@ger.gmane.org>
References <mailman.336.1426284641.21433.python-list@python.org> <877fuk71fz.fsf@nightsong.com> <CAPTjJmoxL0ux3mHAd8UCZmdbTHe_Yz5i9Y8XrzJ7NAuy8WZ4sA@mail.gmail.com> <me1k2i$ljt$1@ger.gmane.org>
Date Sun, 15 Mar 2015 02:52:07 +1100
Subject Re: Odd ValueError using float
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.356.1426348329.21433.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Mar 15, 2015 at 2:28 AM, emile <emile@fenx.com> wrote:
> It ran almost to completion before generating the error again --
>
> (Pdb) decval
> '4'
> (Pdb) type(decval)
> <type 'str'>
> (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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Odd ValueError using float emile <emile@fenx.com> - 2015-03-13 15:10 -0700
  Re: Odd ValueError using float Paul Rubin <no.email@nospam.invalid> - 2015-03-13 19:33 -0700
    Re: Odd ValueError using float Chris Angelico <rosuav@gmail.com> - 2015-03-14 14:09 +1100
    Re: Odd ValueError using float emile <emile@fenx.com> - 2015-03-14 08:28 -0700
    Re: Odd ValueError using float Chris Angelico <rosuav@gmail.com> - 2015-03-15 02:52 +1100
    Re: Odd ValueError using float Peter Otten <__peter__@web.de> - 2015-03-14 17:08 +0100
    Re: Odd ValueError using float emile <emile@fenx.com> - 2015-03-14 10:08 -0700
    Re: Odd ValueError using float emile <emile@fenx.com> - 2015-03-14 10:17 -0700
    Re: Odd ValueError using float Peter Otten <__peter__@web.de> - 2015-03-14 19:24 +0100
    Re: Odd ValueError using float emile <emile@fenx.com> - 2015-03-14 13:01 -0700
    Re: Odd ValueError using float Peter Otten <__peter__@web.de> - 2015-03-15 15:01 +0100
    Re: Odd ValueError using float emile <emile@fenx.com> - 2015-03-17 13:48 -0700

csiph-web