[Python-bugs-list] string bug in atoi (PR#55)

sergio@mnc.md sergio@mnc.md
Thu, 19 Aug 1999 08:50:54 -0400 (EDT)


Full_Name: Sergio Baca
Version: 1.52 and JPython last beta
OS: Windows NT
Submission from: sergio.mnc.md (212.0.192.40)


I have found error in string module. This is a test program:
---
from string import atoi
str1 = "0x8e"
print atoi(str1, 16)
print atoi(str1)
---

As I can read from documentation:
---
atoi (s[, base]) 
     Convert string s to an integer in the given base. The string must consist
of one or more digits, optionally preceded by a sign ("+" or "-"). The base
defaults to 10. If it is 0, a default base is chosen depending on the leading
characters of the string (after stripping the sign): "0x" or "0X" means 16, "0"
means 8, anything else means 10. If base is 16, a leading "0x" or "0X" is always
accepted. Note that when invoked without base or with base set to 10, this
behaves identical to the built-in function int() when passed a string. (Also
note: for a more flexible interpretation of numeric literals, use the    
built-in function eval().) 
---

Both cases should work good, but in both cases I receive error. In first case:
---
Traceback (innermost last):
  File "stringTest.py", line 3, in ?
  File "D:\WINNT\Profiles\sergio1\JPython-1.1beta2\Lib\string.py", line 228, in
atoi
TypeError: int$(): expected 1 args; got 2
---
And in second:
---
Traceback (innermost last):
  File "stringTest.py", line 4, in ?
  File "D:\WINNT\Profiles\sergio1\JPython-1.1beta2\Lib\string.py", line 228, in
atoi
ValueError: invalid literal for __int__: 0x8e
---

Identical error messages I receive in Python 1.52 Please write me if I'm doing
something wrong.