Changes by Serhiy Storchaka storch...@gmail.com:
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
Roundup Robot added the comment:
New changeset ecc8512b427d by Serhiy Storchaka in branch '3.3':
Issue #16741: Fix an error reporting in int().
http://hg.python.org/cpython/rev/ecc8512b427d
New changeset 4fd48a807812 by Serhiy Storchaka in branch 'default':
Issue #16741: Fix an error reporting
Changes by Serhiy Storchaka storch...@gmail.com:
--
resolution: - fixed
stage: patch review - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
Serhiy Storchaka added the comment:
There is a test in test_unicode which expects an UnicodeError for
int('\ud800'). Now it fails. Should we fix a test or int()?
--
resolution: fixed -
status: closed - open
___
Python tracker rep...@bugs.python.org
Alexander Belopolsky added the comment:
I'd say fix the test. Raising ValueError is correct in this case.
UnicodeError was an implementation artifact.
--
nosy: +belopolsky
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
Roundup Robot added the comment:
New changeset 7b023134ad83 by Serhiy Storchaka in branch '3.3':
Issue #16741: Remove testing of implementation artifact.
http://hg.python.org/cpython/rev/7b023134ad83
New changeset 1b4772ab420f by Serhiy Storchaka in branch 'default':
Issue #16741: Remove
Serhiy Storchaka added the comment:
If there are no objections I'm going to commit patches soon.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
Christian Heimes added the comment:
I don't like the idea to change the behavior of 2.7 so late in its release
cycle. Benjamin, what's your opinion?
--
nosy: +benjamin.peterson, christian.heimes
___
Python tracker rep...@bugs.python.org
Benjamin Peterson added the comment:
Yeah, let's just fix Python 3.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
Serhiy Storchaka added the comment:
Here is a patch for 2.7.
--
Added file: http://bugs.python.org/file30916/int_from_str-2.7.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
Serhiy Storchaka added the comment:
Patch updated. It now reuses code for bytes-int in longobject.c and
abstract.c, doesn't raise UnicodeDecodeError for non-utf-8 bytes, and always
reports an invalid bytes literal as a bytes object.
--
Added file:
Serhiy Storchaka added the comment:
Are there any other comments?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
Python-bugs-list
Serhiy Storchaka added the comment:
Thanks, for 3.4 I will use new formatting feature.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
Serhiy Storchaka added the comment:
Here is a patch based on Matthew's patch. It is smaller (+35 lines vs +59) but
fixes error messages for more cases:
int(b'123\0') -- bytes string with null without base.
int(b'123\xbd') -- non-utf-8 bytes string.
int('123\ud800') -- lone surrogate in unicode
Changes by Serhiy Storchaka storch...@gmail.com:
--
assignee: - serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
STINNER Victor added the comment:
int_from_str.patch:
+strobj = PySequence_GetSlice(u, 0, 200);
+if (strobj != NULL) {
+PyErr_Format(PyExc_ValueError,
+ invalid literal for int() with base %d: %R,
+ base, strobj);
+
Changes by Martin Morrison m...@ensoft.co.uk:
--
nosy: +isoschiz
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
Python-bugs-list
Matthew Barnett added the comment:
I've attached a small additional patch for truncating the UTF-8.
I don't know whether it's strictly necessary, but I don't know that it's
unnecessary either! (Better safe than sorry.)
--
Added file: http://bugs.python.org/file28492/issue16741#2.patch
Changes by Serhiy Storchaka storch...@gmail.com:
--
nosy: +serhiy.storchaka
versions: +Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
Matthew Barnett added the comment:
I've attached a patch.
It now reports an invalid literal as-is:
int(#\N{ARABIC-INDIC DIGIT ONE})
Traceback (most recent call last):
File pyshell#1, line 1, in module
int(#\N{ARABIC-INDIC DIGIT ONE})
ValueError: invalid literal for int() with base 10:
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +ezio.melotti, haypo
stage: - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
Matthew Barnett added the comment:
It occurred to me that the truncation of the string when building the error
message could cause a UnicodeDecodeError:
int(1.ljust(199) + \u0100)
Traceback (most recent call last):
File pyshell#0, line 1, in module
int(1.ljust(199) + \u0100)
Changes by Terry J. Reedy tjre...@udel.edu:
--
versions: -Python 2.6, Python 3.1
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
Matthew Barnett added the comment:
Python takes a long way round when converting strings to int. It does the
following (I'll be talking about Python 3.3 here):
1. In function 'fix_decimal_and_space_to_ascii', the different kinds of spaces
are converted to and the different kinds of digits
New submission from ganges master:
I'm not sure if it's a bug or just an inconvenience, but when a string
containing \x00 is passed to int/float/etc, they return a misleading exception:
int(abc)
Traceback (most recent call last):
File stdin, line 1, in module
ValueError:
Changes by Benjamin Peterson benja...@python.org:
--
nosy: +mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16741
___
___
26 matches
Mail list logo