cpython/Objects
Thomas Wouters 9cb28bea04 Fix int() and long() to repr() their argument when formatting the exception,
to avoid confusing situations like:

>>> int("")
ValueError: invalid literal for int():
>>> int("2\n\n2")
ValueError: invalid literal for int(): 2

2

Also report the base used, to avoid:

ValueError: invalid literal for int(): 2

They now report:

>>> int("")
ValueError: invalid literal for int() with base 10: ''
>>> int("2\n\n2")
ValueError: invalid literal for int() with base 10: '2\n\n2'
>>> int("2", 2)
ValueError: invalid literal for int() with base 2: '2'

(Reporting the base could be avoided when base is 10, which is the default,
but hrm.) Another effect of these changes is that the errormessage can be
longer; before, it was cut off at about 250 characters. Now, it can be up to
four times as long, as the unrepr'ed string is cut off at 200 characters,
instead.

No tests were added or changed, since testing for exact errormsgs is (pardon
the pun) somewhat errorprone, and I consider not testing the exact text
preferable. The actually changed code is tested frequent enough in the
test_builtin test as it is (120 runs for each of ints and longs.)
2006-04-11 23:50:33 +00:00
..
abstract.c Minor bugs in the __index__ code (PEP 357), with tests. 2006-03-30 14:04:02 +00:00
boolobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
bufferobject.c More C++-compliance. Note especially listobject.c - to get C++ to accept the 2006-04-11 06:54:30 +00:00
cellobject.c Previously, Python code had no easy way to access the contents of a 2006-03-18 07:59:59 +00:00
classobject.c More C++-compliance. Note especially listobject.c - to get C++ to accept the 2006-04-11 06:54:30 +00:00
cobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
codeobject.c Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
complexobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
descrobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
dictnotes.txt Fix typos and add some elaborations 2004-03-15 15:52:22 +00:00
dictobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
enumobject.c More C++-compliance. Note especially listobject.c - to get C++ to accept the 2006-04-11 06:54:30 +00:00
fileobject.c More C++-compliance. Note especially listobject.c - to get C++ to accept the 2006-04-11 06:54:30 +00:00
floatobject.c More C++-compliance. Note especially listobject.c - to get C++ to accept the 2006-04-11 06:54:30 +00:00
frameobject.c Use macro versions instead of function versions when we already know the type. 2006-03-20 01:53:23 +00:00
funcobject.c Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
genobject.c SF Patch #1463867: Improved generator finalization to allow generators 2006-04-10 17:51:05 +00:00
intobject.c Fix int() and long() to repr() their argument when formatting the exception, 2006-04-11 23:50:33 +00:00
iterobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
listobject.c More C++-compliance. Note especially listobject.c - to get C++ to accept the 2006-04-11 06:54:30 +00:00
listsort.txt The key to the various sort columns got lost. Pulled from 2005-09-23 17:14:22 +00:00
longobject.c Fix int() and long() to repr() their argument when formatting the exception, 2006-04-11 23:50:33 +00:00
methodobject.c Use Py_ssize_t for counts and sizes. 2006-02-16 14:32:27 +00:00
moduleobject.c Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
object.c _Py_PrintReferenceAddresses,_Py_PrintReferences: 2006-04-11 19:12:33 +00:00
obmalloc.c Get compiling again 2006-04-11 07:58:54 +00:00
rangeobject.c Remove "static forward" declaration. Move constructors 2006-04-11 09:04:12 +00:00
setobject.c Remove "static forward" declaration. Move constructors 2006-04-11 09:04:12 +00:00
sliceobject.c Allow long integers in PySlice_GetIndices. 2006-04-03 11:38:08 +00:00
stringobject.c More low-hanging fruit. Still need to re-arrange some code (or find a better 2006-04-11 07:42:36 +00:00
structseq.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
tupleobject.c Remove "static forward" declaration. Move constructors 2006-04-11 09:04:12 +00:00
typeobject.c Correct casts to char*. 2006-04-11 09:08:02 +00:00
unicodectype.c Enhance the performance of two important Unicode character 2005-10-20 19:06:35 +00:00
unicodeobject.c More low-hanging fruit. Still need to re-arrange some code (or find a better 2006-04-11 07:42:36 +00:00
unicodetype_db.h Update Unicode database to Unicode 4.1. 2006-03-09 23:38:20 +00:00
weakrefobject.c Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00