This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: int() raises UnicodeDecodeError when called on malformed string
Type: behavior Stage: test needed
Components: Interpreter Core Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: Inconsistent Exception for int() conversion
View: 7710
Assigned To: Nosy List: belopolsky, ezio.melotti, flox, mark.dickinson
Priority: normal Keywords:

Created on 2010-08-12 17:52 by belopolsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg113694 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-08-12 17:52
>>> int('\xA11')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa1 in position 0: invalid start byte

This is inconsistent with other number types' behavior: 
>>> float(b'\xA1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: �
msg113696 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-08-12 18:09
a duplicate of #7710
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53787
2010-08-12 18:09:27floxsetstatus: open -> closed

nosy: + flox
messages: + msg113696

superseder: Inconsistent Exception for int() conversion
resolution: duplicate
2010-08-12 17:54:24ezio.melottisetversions: + Python 3.1, Python 2.7, Python 3.2
nosy: + ezio.melotti

components: + Interpreter Core
type: behavior
stage: test needed
2010-08-12 17:52:36belopolskycreate