summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2007-08-26 22:27:13 (GMT)
committerEric Smith <eric@trueblade.com>2007-08-26 22:27:13 (GMT)
commit7ade6485abde95c5cc9676ad3e476ba3aca98037 (patch)
treefa5710899c3e376f89eb6a6460e06f3feee62d58 /Python/sysmodule.c
parent2bf4d5ba2881725bb7695bc0573bab0e2ca4fec5 (diff)
downloadcpython-7ade6485abde95c5cc9676ad3e476ba3aca98037.zip
cpython-7ade6485abde95c5cc9676ad3e476ba3aca98037.tar.gz
cpython-7ade6485abde95c5cc9676ad3e476ba3aca98037.tar.bz2
PEP 3101: Completed string.Formatter class. Reimplemented field_name to object transformation.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 10a7427..0c84db0 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -683,28 +683,28 @@ sys_formatter_iterator(PyObject *self, PyObject *args)
return _unicodeformatter_iterator(str);
}
-/* sys_formatter_lookup is used to implement string.Formatter.vformat.
- it takes an PEP 3101 "field name", args, and kwargs, and returns a
- tuple (index, name, object). see unicodeobject.c's
- _unicodeformatter_lookup for details */
+/* sys_formatter_field_name_split is used to implement
+ string.Formatter.vformat. it takes an PEP 3101 "field name", and
+ returns a tuple of (first, rest): "first", the part before the
+ first '.' or '['; and "rest", an iterator for the rest of the field
+ name. see unicodeobjects' _unicode_formatter_field_name_split for
+ details */
static PyObject *
-sys_formatter_lookup(PyObject *self, PyObject *args)
+sys_formatter_field_name_split(PyObject *self, PyObject *args)
{
PyObject *field_name;
- PyObject *arg_args;
- PyObject *kwargs;
- if (!PyArg_ParseTuple(args, "OOO:_formatter_lookup", &field_name,
- &arg_args, &kwargs))
+ if (!PyArg_ParseTuple(args, "O:_formatter_field_name_split",
+ &field_name))
return NULL;
if (!PyUnicode_Check(field_name)) {
- PyErr_SetString(PyExc_TypeError,
- "_formatter_lookup expects unicode object");
+ PyErr_SetString(PyExc_TypeError, "_formatter_field_name_split "
+ "expects unicode object");
return NULL;
}
- return _unicodeformatter_lookup(field_name, arg_args, kwargs);
+ return _unicodeformatter_field_name_split(field_name);
}
@@ -773,7 +773,8 @@ static PyMethodDef sys_methods[] = {
{"_current_frames", sys_current_frames, METH_NOARGS,
current_frames_doc},
{"_formatter_parser", sys_formatter_iterator, METH_VARARGS},
- {"_formatter_lookup", sys_formatter_lookup, METH_VARARGS},
+ {"_formatter_field_name_split", sys_formatter_field_name_split,
+ METH_VARARGS},
{"displayhook", sys_displayhook, METH_O, displayhook_doc},
{"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc},
{"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc},