I think there may be a bug in string.atoi and string.atol. Here's some
output from idle.
[color=blue]
> Python 2.3.4 (#2, Jan 5 2005, 08:24:51)
> [GCC 3.3.5 (Debian 1:3.3.5-5)] on linux2
> Type "copyright" , "credits" or "license()" for more information.
>
> *************** *************** *************** *************** ****
> Personal firewall software may warn about the connection IDLE
> makes to its subprocess using this computer's internal loopback
> interface. This connection is not visible on any external
> interface and no data is sent to or received from the Internet.
> *************** *************** *************** *************** ****
>
> IDLE 1.0.4[color=green][color=darkred]
>>>> import string as s
>>>> s.atoi('2',3)[/color][/color]
> 2[color=green][color=darkred]
>>>> s.atoi('4',3)[/color][/color]
>
> Traceback (most recent call last):
> File "<pyshell#2 >", line 1, in -toplevel-
> s.atoi('4',3)
> File "/usr/lib/python2.3/string.py", line 220, in atoi
> return _int(s, base)
> ValueError: invalid literal for int(): 4[color=green][color=darkred]
>>>> s.atoi('12',11)[/color][/color]
> 13[color=green][color=darkred]
>>>> s.atoi('13',4)[/color][/color]
> 7[color=green][color=darkred]
>>>> s.atoi('12',4)[/color][/color]
> 6[color=green][color=darkred]
>>>> s.atoi('8',4)[/color][/color]
>
> Traceback (most recent call last):
> File "<pyshell#6 >", line 1, in -toplevel-
> s.atoi('8',4)
> File "/usr/lib/python2.3/string.py", line 220, in atoi
> return _int(s, base)
> ValueError: invalid literal for int(): 8[color=green][color=darkred]
>>>>[/color][/color][/color]
s.atoi('4',3) should result in 11
s.atoi('13',4) should result in 31
s.atoi('12',4) should result in 30
s.atoi('8',4) is legitimate, but it generates an error.
Is this a bug, or am I missing something obvious?
TIA,
Mike
output from idle.
[color=blue]
> Python 2.3.4 (#2, Jan 5 2005, 08:24:51)
> [GCC 3.3.5 (Debian 1:3.3.5-5)] on linux2
> Type "copyright" , "credits" or "license()" for more information.
>
> *************** *************** *************** *************** ****
> Personal firewall software may warn about the connection IDLE
> makes to its subprocess using this computer's internal loopback
> interface. This connection is not visible on any external
> interface and no data is sent to or received from the Internet.
> *************** *************** *************** *************** ****
>
> IDLE 1.0.4[color=green][color=darkred]
>>>> import string as s
>>>> s.atoi('2',3)[/color][/color]
> 2[color=green][color=darkred]
>>>> s.atoi('4',3)[/color][/color]
>
> Traceback (most recent call last):
> File "<pyshell#2 >", line 1, in -toplevel-
> s.atoi('4',3)
> File "/usr/lib/python2.3/string.py", line 220, in atoi
> return _int(s, base)
> ValueError: invalid literal for int(): 4[color=green][color=darkred]
>>>> s.atoi('12',11)[/color][/color]
> 13[color=green][color=darkred]
>>>> s.atoi('13',4)[/color][/color]
> 7[color=green][color=darkred]
>>>> s.atoi('12',4)[/color][/color]
> 6[color=green][color=darkred]
>>>> s.atoi('8',4)[/color][/color]
>
> Traceback (most recent call last):
> File "<pyshell#6 >", line 1, in -toplevel-
> s.atoi('8',4)
> File "/usr/lib/python2.3/string.py", line 220, in atoi
> return _int(s, base)
> ValueError: invalid literal for int(): 8[color=green][color=darkred]
>>>>[/color][/color][/color]
s.atoi('4',3) should result in 11
s.atoi('13',4) should result in 31
s.atoi('12',4) should result in 30
s.atoi('8',4) is legitimate, but it generates an error.
Is this a bug, or am I missing something obvious?
TIA,
Mike
Comment