Re: Odd ValueError using float

2015-03-17 Thread emile
On 03/15/2015 07:01 AM, Peter Otten wrote: 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

Re: Odd ValueError using float

2015-03-15 Thread Peter Otten
emile wrote: > On 03/14/2015 11:24 AM, Peter Otten wrote: >> emile wrote: >> >>> On 03/14/2015 09:08 AM, Peter Otten wrote: > Why are you checking int(decval) >>> >>> >>> because it sure smells like int should work: >>> >>> (Pdb) "3">> True >> >> That's a normal string comparison w

Re: Odd ValueError using float

2015-03-15 Thread random832
On Sat, Mar 14, 2015, at 18:09, Cameron Simpson wrote: > >So there's still something amiss. > > Am I missing something obvious here? int() likes only ints, not floats: What you're missing is that when directly examined in pdb, the value appeared to be '4', but then when passed to the int construc

Re: Odd ValueError using float

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 9:09 AM, Cameron Simpson wrote: > On 14Mar2015 08:28, Emile van Sebille 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: inval

Re: Odd ValueError using float

2015-03-14 Thread Cameron Simpson
On 14Mar2015 08:28, Emile van Sebille 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.703' So there's still something amiss

Re: Odd ValueError using float

2015-03-14 Thread emile
On 03/14/2015 11:24 AM, Peter Otten wrote: emile wrote: On 03/14/2015 09:08 AM, Peter Otten wrote: Why are you checking int(decval) because it sure smells like int should work: (Pdb) "3" That's a normal string comparison when decval is a string. This and the ValueError is expected Pyth

Re: Odd ValueError using float

2015-03-14 Thread Peter Otten
emile wrote: > On 03/14/2015 09:08 AM, Peter Otten wrote: >> emile wrote: >> >>> On 03/13/2015 08:09 PM, Chris Angelico wrote: On Sat, Mar 14, 2015 at 1:33 PM, Paul Rubin wrote: > emile writes: >> *** NameError: name 'val' is not defined >> (Pdb) l >> 139 try: >

Re: Odd ValueError using float

2015-03-14 Thread emile
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.70

Re: Odd ValueError using float

2015-03-14 Thread emile
On 03/14/2015 09:08 AM, Peter Otten wrote: emile wrote: On 03/13/2015 08:09 PM, Chris Angelico wrote: On Sat, Mar 14, 2015 at 1:33 PM, Paul Rubin wrote: emile writes: *** NameError: name 'val' is not defined (Pdb) l 139 try: 140 val = round(float(decval),1) 141

Re: Odd ValueError using float

2015-03-14 Thread Peter Otten
emile wrote: > On 03/13/2015 08:09 PM, Chris Angelico wrote: >> On Sat, Mar 14, 2015 at 1:33 PM, Paul Rubin >> wrote: >>> emile writes: *** NameError: name 'val' is not defined (Pdb) l 139 try: 140 val = round(float(decval),1) 141 except:

Re: Odd ValueError using float

2015-03-14 Thread Chris Angelico
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.703' > > So there's

Re: Odd ValueError using float

2015-03-14 Thread emile
On 03/13/2015 08:09 PM, Chris Angelico wrote: On Sat, Mar 14, 2015 at 1:33 PM, Paul Rubin wrote: emile writes: *** NameError: name 'val' is not defined (Pdb) l 139 try: 140 val = round(float(decval),1) 141 except: 142 import pdb; pdb.set_trace() If 'f

Re: Odd ValueError using float

2015-03-13 Thread Chris Angelico
On Sat, Mar 14, 2015 at 1:33 PM, Paul Rubin wrote: > emile writes: >> *** NameError: name 'val' is not defined >> (Pdb) l >> 139 try: >> 140 val = round(float(decval),1) >> 141 except: >> 142 import pdb; pdb.set_trace() > > If 'float' or 'round' throw an ex

Re: Odd ValueError using float

2015-03-13 Thread Paul Rubin
emile writes: > *** NameError: name 'val' is not defined > (Pdb) l > 139 try: > 140 val = round(float(decval),1) > 141 except: > 142 import pdb; pdb.set_trace() If 'float' or 'round' throw an exception, the assignment to 'val' never happens, so 'val' is und

Re: Odd ValueError using float

2015-03-13 Thread emile
On 03/13/2015 03:14 PM, Chris Angelico wrote: On Sat, Mar 14, 2015 at 9:10 AM, emile wrote: (Pdb) decval '4' (Pdb) len(decval) 1 (Pdb) int(decval) *** ValueError: invalid literal for int() with base 10: '41.703' (Pdb) Any ideas? What's type(decval) tell you? I suspect you may ha

Re: Odd ValueError using float

2015-03-13 Thread Chris Angelico
On Sat, Mar 14, 2015 at 9:10 AM, emile wrote: > (Pdb) decval > '4' > (Pdb) len(decval) > 1 > (Pdb) int(decval) > *** ValueError: invalid literal for int() with base 10: '41.703' > (Pdb) > > > Any ideas? What's type(decval) tell you? I suspect you may have something other than a string

Odd ValueError using float

2015-03-13 Thread emile
On an older WinXP SP2 box with python2.6 that's been running this process fine for years, this week we're seeing: > c:\python26\lib\site-packages\fenx\sql_interface.py(144)normalized() -> return val (Pdb) val *** NameError: name 'val' is not defined (Pdb) l 139 try: 140 val =