Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87435
| From | emile <emile@fenx.com> |
|---|---|
| Subject | Re: Odd ValueError using float |
| Date | 2015-03-14 10:17 -0700 |
| References | <mailman.336.1426284641.21433.python-list@python.org> <877fuk71fz.fsf@nightsong.com> <CAPTjJmoxL0ux3mHAd8UCZmdbTHe_Yz5i9Y8XrzJ7NAuy8WZ4sA@mail.gmail.com> <me1k2i$ljt$1@ger.gmane.org> <CAPTjJmqTmcGx9enEG=nT7vz67qZ=xA0VZW1ppgp0xAGexLSJ3A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.364.1426353497.21433.python-list@python.org> (permalink) |
On 03/14/2015 08:52 AM, Chris Angelico wrote:
> 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)))
>
(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
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