New submission from Alexander Belopolsky <belopol...@users.sourceforge.net>:
>>> float('½') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: could not convert string to float: � >>> float('42½') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError With the attached patch, float-error.diff >>> float('½') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for float(): ½ >>> float('42½') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for float(): 42½ Note that the proposed patch also has an effect of disallowing non-ascii digits in float() constructor. Before the patch: >>> float('١٢٣٤.٥٦') 1234.56 After the patch: >>> float('١٢٣٤.٥٦') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: could not convert string to float: ١٢٣٤.٥٦ I am not sure, whether support for non-ascii digits in float() constructor is worth maintaining. (Anyone knows whether Arabic numbers are written right to left or left to right? What is the proper decimal point character?) Also, I don't think users expect UnicodeEncodeError from float() or int(). Before the patch: >>> float('\uffff') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'decimal' codec can't encode character '\uffff' in position 0: invalid decimal Unicode string After the patch: >>> float('\uffff') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: could not convert string to float: � ---------- components: Interpreter Core files: float-error.diff keywords: patch messages: 122612 nosy: belopolsky, ezio.melotti, haypo, mark.dickinson priority: normal severity: normal stage: unit test needed status: open title: Malformed error message from float() type: behavior versions: Python 3.2 Added file: http://bugs.python.org/file19848/float-error.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10557> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com