[New-bugs-announce] [issue7710] Inconsistent Exception for int() conversion

Florent Xicluna report at bugs.python.org
Fri Jan 15 20:35:23 CET 2010


New submission from Florent Xicluna <laxyf at yahoo.fr>:

On Python 3:

>>> int('\0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'decimal' codec can't encode character '\x00' in position 0: invalid decimal Unicode string

>>> int('\01')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '\x01'

>>> int('\x80')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: unexpected code byte

>>> int('\xc0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc0 in position 0: unexpected end of data


On Python 2, it raises ValueError (except for '\0').

----------
components: Interpreter Core
messages: 97839
nosy: flox
severity: normal
status: open
title: Inconsistent Exception for int() conversion
versions: Python 3.2

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


More information about the New-bugs-announce mailing list