[New-bugs-announce] [issue4221] inconsistent exception from int is confusing

Jean-Paul Calderone report at bugs.python.org
Tue Oct 28 18:11:57 CET 2008


New submission from Jean-Paul Calderone <exarkun at divmod.com>:

exarkun at charm:~$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> int('\0', 256)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 256: '\x00'
>>> int('x', 256)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: int() base must be >= 2 and <= 36
>>> 

The former is misleading.  \x00 is a perfectly valid byte if the base is
256.  The real problem, that base 256 isn't supported, is obscured.  It
would be much better for the latter case's message to be used in the
former case.

----------
components: Interpreter Core
messages: 75290
nosy: exarkun
severity: normal
status: open
title: inconsistent exception from int is confusing
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4221>
_______________________________________


More information about the New-bugs-announce mailing list