[Python-checkins] r71545 - python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h
eric.smith
python-checkins at python.org
Mon Apr 13 01:33:18 CEST 2009
Author: eric.smith
Date: Mon Apr 13 01:33:18 2009
New Revision: 71545
Log:
Improved error detecttion with ',' modifier.
Modified:
python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h
Modified: python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h
==============================================================================
--- python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h (original)
+++ python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h Mon Apr 13 01:33:18 2009
@@ -230,10 +230,27 @@
++ptr;
}
- /* XXX other types like xobXOB also invalid */
- if (format->type == 'n' && format->thousands_separators) {
- PyErr_Format(PyExc_ValueError, "Cannot specify ',' with 'n'.");
- return 0;
+ /* Do as much validating as we can, just by looking at the format
+ specifier. Do not take into account what type of formatting
+ we're doing (int, float, string). */
+
+ if (format->thousands_separators) {
+ switch (format->type) {
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'E':
+ case 'G':
+ case '%':
+ case 'F':
+ /* These are allowed. See PEP 378.*/
+ break;
+ default:
+ PyErr_Format(PyExc_ValueError,
+ "Cannot specify ',' with '%c'.", format->type);
+ return 0;
+ }
}
return 1;
More information about the Python-checkins
mailing list