[Python-Dev] string.ato? and Unicode

Mark Hammond mhammond@skippinet.com.au
Sun, 2 Apr 2000 09:53:50 +1000


Is this an over-sight, or by design?

>>> string.atoi(u"1")
...
TypeError: argument 1: expected string, unicode found

It appears easy to support Unicode - there is already an explicit
StringType check in these functions, and it simply delegates to
int(), which already _does_ work for Unicode

A patch would leave the following behaviour:
>>> string.atio(u"1")
1
>>> string.atio(u"1", 16)
...
TypeError: can't convert non-string with explicit base

IMO, this is better than what we have now.  I'll put together a
patch if one is wanted...

Mark.