mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Implementation of PEP 3101, Advanced String Formatting.
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.
This commit is contained in:
parent
e4dc324884
commit
8c66326368
22 changed files with 2669 additions and 18 deletions
|
@ -5,6 +5,8 @@
|
|||
#include "Python.h"
|
||||
#include "longintrepr.h"
|
||||
|
||||
#include "formatter_unicode.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
long
|
||||
|
@ -3592,6 +3594,16 @@ long_getN(PyLongObject *v, void *context) {
|
|||
return PyLong_FromLong((intptr_t)context);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
long__format__(PyObject *self, PyObject *args)
|
||||
{
|
||||
/* when back porting this to 2.6, check type of the format_spec
|
||||
and call either unicode_long__format__ or
|
||||
string_long__format__ */
|
||||
return unicode_long__format__(self, args);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
long_round(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -3632,6 +3644,7 @@ static PyMethodDef long_methods[] = {
|
|||
"Rounding an Integral returns itself.\n"
|
||||
"Rounding with an ndigits arguments defers to float.__round__."},
|
||||
{"__getnewargs__", (PyCFunction)long_getnewargs, METH_NOARGS},
|
||||
{"__format__", (PyCFunction)long__format__, METH_VARARGS},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue