formatting.
Includes:
- Modifying tests for basic types to use __format__ methods, instead
of builtin "format".
- Adding PyObject_Format.
- General str/unicode cleanup discovered when backporting to 2.6.
- Removing datetimemodule.c's time_format, since it was identical
to date_format.
The files in Objects/stringlib that implement PEP 3101 (stringdefs.h,
unicodedefs.h, formatter.h, string_format.h) are identical in trunk
and py3k. Any changes from here on should be made to trunk, and
changes will propogate to py3k).
Corrected code for invalid conversion specifier.
Added tests to verify.
Modified string.Formatter to correctly expand format_spec's,
and added a limit to recursion depth. Added _vformat()
method to support both of these.
a tuple (literal, field_name, format_spec, conversion).
literal will always be a string, but might be of zero length.
field_name will be None if there is no markup text
format_spec will be a (possibly zero length) string if
field_name is non-None
conversion will be a one character string, or None
This makes the Formatter class, and especially it's parse()
method, easier to understand.
Suggestion was by Jim Jewett, inspired by the "tail" of an
elementtree node.
Also, fixed a reference leak in fieldnameiter_next.
4 elements. No need for old is_markup element, the same information
is indicated by literal_string being None.
Factored string.Formatter class to make subclasses easier to write.
Known issues:
The string.Formatter class, as discussed in the PEP, is incomplete.
Error handling needs to conform to the PEP.
Need to fix this warning that I introduced in Python/formatter_unicode.c:
Objects/stringlib/unicodedefs.h:26: warning: `STRINGLIB_CMP' defined but not used
Need to make sure sign formatting is correct, more tests needed.
Need to remove '()' sign formatting, left over from an earlier version of the PEP.