This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mathieui
Recipients ezio.melotti, mathieui
Date 2013-03-01.20:53:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1362171220.98.0.881684038408.issue17331@psf.upfronthosting.co.za>
In-reply-to
Content
In py3k, str.isalnum(), str.isdigit(), and str.isdecimal() are broken because they take into account various unicode numbers.

A common case is doing something like that:

num = -1
while num == -1:
    num_in = input('Enter a number> ')
    if num_in.isdigit():
        num = int(num_in)

# do stuff …

If you enter ¹, or any esoteric unicode representation of a number, all the methods referenced above will return True. I believe this is a bug.

It also affects the stdlib, e.g. in collection.namedtuple,
A = namedtuple('A¹', 'x y') will return an ugly Syntax Error, because the sanity check uses str.isalnum(), which says it’s ok. (n.b.: of course, no sane person should ever want to do the above, but I find it worth mentionning)
History
Date User Action Args
2013-03-01 20:53:41mathieuisetrecipients: + mathieui, ezio.melotti
2013-03-01 20:53:40mathieuisetmessageid: <1362171220.98.0.881684038408.issue17331@psf.upfronthosting.co.za>
2013-03-01 20:53:40mathieuilinkissue17331 messages
2013-03-01 20:53:40mathieuicreate