Go ahead and fix it. This was probably never changed since 1990 or so... Do expect some code brakage where people rely on the old behavior. :-(
--Guido On 4/9/06, Thomas Wouters <[EMAIL PROTECTED]> wrote: > > Someone on IRC (who refuses to report bugs on sourceforge, so I guess he > wants to remain anonymous) came with this very amusing bug: int(), when > raising ValueError, doesn't quote (or repr(), rather) its arguments: > > >>> int("") > Traceback (most recent call last): > File "<stdin>", line 1, in ? > ValueError: invalid literal for int(): > >>> int("34\n\n\n5") > Traceback (most recent call last): > File "<stdin>", line 1, in ? > ValueError: invalid literal for int(): 34 > > > 5 > >>> > > Unicode behaviour also isn't always consistent: > >>> int(u'\u0100') > Traceback (most recent call last): > File "<stdin>", line 1, in ? > UnicodeEncodeError: 'decimal' codec can't encode character u'\u0100' in > position 0: invalid decimal Unicode string > >>> int(u'\u09ec', 6) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > ValueError: invalid literal for int(): 6 > > And trying to use the 'decimal' codec directly: > >>> u'6'.encode('decimal') > Traceback (most recent call last): > File "<stdin>", line 1, in ? > LookupError: unknown encoding: decimal > > I'm not sure if the latter problems are fixable, but the former should be > fixed by passing the argument to ValueError through repr(), I think. It's > also been suggested (by the reporter, and I agree) that the actual base > should be in the errormessage too. Is there some reason not to do this that > I've overlooked? > > -- > Thomas Wouters <[EMAIL PROTECTED]> > > Hi! I'm a .signature virus! copy me into your .signature file to help me > spread! > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/guido%40python.org > > > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com