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


Groups > comp.lang.python > #87472

Re: Odd ValueError using float

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'interpreter': 0.05; 'string.': 0.05; 'error:': 0.07; 'versions,': 0.07; 'string': 0.09; 'literal': 0.09; 'meaningful': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'subject:using': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'bug': 0.12; 'itself.': 0.14; '(pdb)': 0.16; 'deletion': 0.16; 'int(s)': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'valueerror': 0.16; 'wrote:': 0.18; 'fit': 0.20; 'written': 0.21; '>>>': 0.22; 'import': 0.22; 'previously': 0.22; 'install': 0.23; 'header:User- Agent:1': 0.23; 'bytes': 0.24; 'extension': 0.26; 'shown': 0.26; 'post': 0.26; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'rest': 0.29; 'am,': 0.29; 'thus': 0.29; "i'm": 0.30; 'that.': 0.31; '"",': 0.31; '>>>>': 0.31; 'bad.': 0.31; 'comparison': 0.31; 'ctypes': 0.31; 'terminate': 0.31; 'work:': 0.31; 'file': 0.32; 'probably': 0.32; 'skip:c 30': 0.32; 'says': 0.33; '(most': 0.33; 'checking': 0.33; 'moment': 0.34; "i'd": 0.34; 'problem': 0.35; 'but': 0.35; 'disk': 0.36; 'tight': 0.36; 'next': 0.36; "i'll": 0.36; 'should': 0.36; 'skip:4 10': 0.37; 'application': 0.37; 'expected': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'explain': 0.39; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'length': 0.61; 'more': 0.64; 'contact': 0.67; 'mar': 0.68; 'yes': 0.68; 'invalid': 0.68; 'unusual': 0.74; '10:': 0.84; '2014,': 0.84; 'object:': 0.84; 'otten': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Odd ValueError using float
Date Sun, 15 Mar 2015 15:01:43 +0100
Organization None
References <mailman.336.1426284641.21433.python-list@python.org> <877fuk71fz.fsf@nightsong.com> <CAPTjJmoxL0ux3mHAd8UCZmdbTHe_Yz5i9Y8XrzJ7NAuy8WZ4sA@mail.gmail.com> <me1k2i$ljt$1@ger.gmane.org> <me1mdb$nri$1@ger.gmane.org> <me1ptc$gna$1@ger.gmane.org> <me1ucs$n98$1@ger.gmane.org> <me2439$cvf$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd80fa.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
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.391.1426428130.21433.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426428130 news.xs4all.nl 2946 [2001:888:2000:d::a6]:54897
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87472

Show key headers only | View raw


emile wrote:

> On 03/14/2015 11:24 AM, Peter Otten wrote:
>> emile wrote:
>>
>>> On 03/14/2015 09:08 AM, Peter Otten wrote:
> <snip>
>>>> Why are you checking
>>>>
>>>> int(decval)
>>>
>>>
>>> because it sure smells like int should work:
>>>
>>> (Pdb) "3"<decval<"5"
>>> True
>>
>> That's a normal string comparison when decval is a string. This and the
>> ValueError is expected Python behaviour:
> 
> 
> yes -- but i'd previously shown decval to have a length of 1, and how
> many things then fit that equation?
> 
> <snip>
> 
>>>> to get a meaningful traceback and post that.
>>>
>>> I don't get a traceback -- it spews:
>>>
>>> Fatal Python error: deletion of interned string failed
>>>
>>> This application has requested the Runtime to terminate it in an unusual
>>> way.
>>> Please contact the application's support team for more information.
>>>
>>> then crashes and I get a Microsoft pop-up that says python.exe has
>>> encountered a problem and needs to close.
>>
>> That does look bad. Most likely an extension written in C corrupts the
>> interpreter or it's even a bug in the interpreter itself.
> 
> I'm tight on time the rest of the day, but I think I'll next zap all the
> pyc versions, install a fresh 2.6.x python, and let it recompile.  About
> the only theory I have at the moment to explain the sudden failure after
> years of non-failure is disk based bit-rot.

Probably not helpful, but I can provoke the behaviour you see by toggling 
bytes with ctypes, thus simulating a corrupted str object:

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> s = "41.700000000000003"
>>> ctypes.c_ubyte.from_address(id(s) + 16).value = 1
>>> s
'4'
>>> len(s)
1
>>> float(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): 41.700000000000003
>>> int(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '41.700000000000003'

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