[Python-checkins] r81822 - in python/branches/release26-maint: Lib/test/test_unicode.py Misc/NEWS Objects/stringlib/string_format.h
benjamin.peterson
python-checkins at python.org
Tue Jun 8 00:27:32 CEST 2010
Author: benjamin.peterson
Date: Tue Jun 8 00:27:32 2010
New Revision: 81822
Log:
Merged revisions 81820 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81820 | benjamin.peterson | 2010-06-07 17:23:23 -0500 (Mon, 07 Jun 2010) | 1 line
correctly overflow when indexes are too large
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Lib/test/test_unicode.py
python/branches/release26-maint/Misc/NEWS
python/branches/release26-maint/Objects/stringlib/string_format.h
Modified: python/branches/release26-maint/Lib/test/test_unicode.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_unicode.py (original)
+++ python/branches/release26-maint/Lib/test/test_unicode.py Tue Jun 8 00:27:32 2010
@@ -1103,6 +1103,9 @@
self.assertRaises(ValueError, u"{:}".format)
self.assertRaises(ValueError, u"{:s}".format)
self.assertRaises(ValueError, u"{}".format)
+ big = "23098475029384702983476098230754973209482573"
+ self.assertRaises(ValueError, ("{" + big + "}").format)
+ self.assertRaises(ValueError, ("{[" + big + "]}").format, [0])
# issue 6089
self.assertRaises(ValueError, u"{0[0]x}".format, [None])
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS (original)
+++ python/branches/release26-maint/Misc/NEWS Tue Jun 8 00:27:32 2010
@@ -18,6 +18,9 @@
when turned into an exception: in this case the exception simply
gets ignored.
+- In the unicode/str.format(), raise a ValueError when either indexes to
+ arguments are too large.
+
- Issue #3798: Write sys.exit() message to sys.stderr to use stderr encoding
and error handler, instead of writing to the C stderr file in utf-8
Modified: python/branches/release26-maint/Objects/stringlib/string_format.h
==============================================================================
--- python/branches/release26-maint/Objects/stringlib/string_format.h (original)
+++ python/branches/release26-maint/Objects/stringlib/string_format.h Tue Jun 8 00:27:32 2010
@@ -327,6 +327,8 @@
if (_FieldNameIterator_item(self, name) == 0)
return 0;
*name_idx = get_integer(name);
+ if (*name_idx == -1 && PyErr_Occurred())
+ return 0;
break;
default:
/* Invalid character follows ']' */
@@ -380,6 +382,8 @@
/* see if "first" is an integer, in which case it's used as an index */
*first_idx = get_integer(first);
+ if (*first_idx == -1 && PyErr_Occurred())
+ return 0;
/* zero length string is an error */
if (first->ptr >= first->end) {
More information about the Python-checkins
mailing list