[docs] Python 3 int() conversion docs misses exception documentation

Albert Hofkamp alberth289346 at gmail.com
Sun Jan 20 21:18:49 CET 2013


In http://docs.python.org/3/library/functions.html#int the int()
operation is described. It does however not say which errors can be
thrown. I found two:

Python 3.2.3 (default, Jun  8 2012, 05:36:09)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> int('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'abc'
>>> int( ('0',) )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string or a number, not 'tuple'
>>>

The former is expected (it happened in Python 2 as well). The latter
is quite unexpected, so I wanted to know when that could happen.


The float() documentation may have similar problems; it only speaks
about OverflowError


Sincerely,
Albert


More information about the docs mailing list