Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87472
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Odd ValueError using float |
| Date | 2015-03-15 15:01 +0100 |
| Organization | None |
| References | (3 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.391.1426428130.21433.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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