New submission from Mathieu Pasquet:

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)

----------
components: Unicode
messages: 183291
nosy: ezio.melotti, mathieui
priority: normal
severity: normal
status: open
title: Fix str methods for detecting digits with unicode
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17331>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to