<br>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:<br><br>
&gt;&gt;&gt; int(&quot;&quot;)<br>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>ValueError: invalid literal for int():<br>&gt;&gt;&gt; int(&quot;34\n\n\n5&quot;)<br>Traceback (most recent call last):
<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>ValueError: invalid literal for int(): 34<br><br><br>5<br>&gt;&gt;&gt;<br><br>Unicode behaviour also isn't always consistent:<br>&gt;&gt;&gt; int(u'\u0100')<br>Traceback (most recent call last):
<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>UnicodeEncodeError: 'decimal' codec can't encode character u'\u0100' in position 0: invalid decimal Unicode string<br>&gt;&gt;&gt; int(u'\u09ec', 6)<br>Traceback (most recent call last):
<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>ValueError: invalid literal for int(): 6<br><br>And trying to use the 'decimal' codec directly:<br>&gt;&gt;&gt; u'6'.encode('decimal')<br>Traceback (most recent call last):
<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>LookupError: unknown encoding: decimal<br><br>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?
<br><br>-- <br>Thomas Wouters &lt;<a href="mailto:thomas@python.org">thomas@python.org</a>&gt;<br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!