Message183291
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) |
|
Date |
User |
Action |
Args |
2013-03-01 20:53:41 | mathieui | set | recipients:
+ mathieui, ezio.melotti |
2013-03-01 20:53:40 | mathieui | set | messageid: <1362171220.98.0.881684038408.issue17331@psf.upfronthosting.co.za> |
2013-03-01 20:53:40 | mathieui | link | issue17331 messages |
2013-03-01 20:53:40 | mathieui | create | |
|