Mailing List Archive

string.atoi('-')
I had the following problem:

With python 1.51 running on a SGI:
>>> string.atoi('-')
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for atoi(): -
>>>

But with python 1.52 running on a SGI:
>>> string.atoi('-')
0
>>>

Does it depend on the compilation?
Does anyone have the same problem?

WHAT IS THE RULE?



Thank you in advance.

Jens
string.atoi('-') [ In reply to ]
[Jens Linge]
> With python 1.51 running on a SGI:
> >>> string.atoi('-')
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> ValueError: invalid literal for atoi(): -
> >>>
>
> But with python 1.52 running on a SGI:
> >>> string.atoi('-')
> 0
> >>>

1.5.2 on Windows:

D:\Python>python
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> string.atoi('-')
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for atoi(): -
>>>

> Does it depend on the compilation?

I'd try recompiling Python with optimization disabled and see whether that
it makes it go away. If so, you're looking at a compiler bug.

> WHAT IS THE RULE?

Do unto others as you would have them do unto you? Something like that.

but-so-far-as-ints-go-"-"-ain't-one-ly y'rs - tim
string.atoi('-') [ In reply to ]
(cc'ed to Jens Linge <linge@embl-heidelberg.de>, the author of)
> With python 1.51 running on a SGI:
> >>> string.atoi('-')
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> ValueError: invalid literal for atoi(): -
> >>>
>
> But with python 1.52 running on a SGI:
> >>> string.atoi('-')
> 0
> >>>
>
> Does it depend on the compilation?
> Does anyone have the same problem?
>
> WHAT IS THE RULE?

My 1.5.1 installation on IRIX 6.2 and 6.5 (compiled under 6.2
with the 7.1 compiler using -o32) says:

val> python
Python 1.5.1 (#21, Nov 23 1998, 15:04:47) [C] on irix6
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> string.atoi('-')
0

so it isn't a 1.5.1 to 1.5.2 difference or a difference in
the -o32 libraries for the OS version. I suspect either the
compiler or the -n32 libs.


I compiled 1.5.2c1 with the newer compiler using -n32. The
result is the error you got:

max> ./python
Python 1.5.2c1 (#5, Apr 29 1999, 19:04:33) [C] on irix646
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> string.atoi('-')
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for atoi(): -

I recompiled 152c1 for SGI_ABI = -o32 on the same machine and
compiler.

max> ./python
Python 1.5.2c1 (#6, Apr 29 1999, 19:12:12) [C] on irix646-o32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> string.atoi('-')
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for atoi(): -


This suggests that the compiler changed a bit (fixed a bug it
seems) and that you are compiling 1.5.2 on the 7.1 compiler while
you compiled 1.5.1 on the 7.2 compiler.

Can you try other combinations of machines and compilers? Or
perhaps change the ABI to -n32 (or -o32) to get a different
set of library routines?

Andrew
dalke@bioreason.com
string.atoi('-') [ In reply to ]
In article <372904D7.1A9FC1AB@bioreason.com>, Andrew Dalke
<dalke@bioreason.com> wrote:

> (cc'ed to Jens Linge <linge@embl-heidelberg.de>, the author of)
> > With python 1.51 running on a SGI:
> > >>> string.atoi('-')
> > Traceback (innermost last):
> > File "<stdin>", line 1, in ?
> > ValueError: invalid literal for atoi(): -
> > >>>
> >
> > But with python 1.52 running on a SGI:
> > >>> string.atoi('-')
> > 0
> > >>>
> >
> > Does it depend on the compilation?
> > Does anyone have the same problem?
> >
> > WHAT IS THE RULE?

The rule is: for the sake of sanity, do not present atoi() with the string '-'.

--John

--
If nothing is pressing, putter about with this or that.
(Fortune cookie)
John W. Baxter Port Ludlow, WA USA jwb@olympus.net