11 Dec
2002
11 Dec
'02
3 p.m.
I think this would be a useful note for the Zope3 style guide.
What exceptions can int() raise?
On converting a preexisting value to an int:
ValueError, OverflowError, TypeError, AttributeError
(Any others?)
On converting an instance that implements __int__:
Anything at all. It can even return a non-int value.
On evaluating the expression inside the int() brackets:
Anything at all.
Anything can raise MemoryError. On converting an 8bit string to an int: ValueError *only* On converting a Unicode string to an int: ValueError UnicodeError (or UnicodeEncodeError, which is a subclass of it) --Guido van Rossum (home page: http://www.python.org/~guido/)