summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-10-14 07:04:07 (GMT)
committerGeorg Brandl <georg@python.org>2010-10-14 07:04:07 (GMT)
commit66c221e993bf7c5979145dbbe365238f2d70064f (patch)
tree75394c24f6343e932125b9a35a9fbea401fe4812 /Objects
parent268e4d4cf36ad79e71438fd864160892b335388d (diff)
downloadcpython-66c221e993bf7c5979145dbbe365238f2d70064f.zip
cpython-66c221e993bf7c5979145dbbe365238f2d70064f.tar.gz
cpython-66c221e993bf7c5979145dbbe365238f2d70064f.tar.bz2
#9418: first step of moving private string methods to _string module.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringlib/string_format.h4
-rw-r--r--Objects/unicodeobject.c32
2 files changed, 32 insertions, 4 deletions
diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h
index bc70e97..126c870 100644
--- a/Objects/stringlib/string_format.h
+++ b/Objects/stringlib/string_format.h
@@ -1180,7 +1180,7 @@ static PyTypeObject PyFormatterIter_Type = {
describing the parsed elements. It's a wrapper around
stringlib/string_format.h's MarkupIterator */
static PyObject *
-formatter_parser(STRINGLIB_OBJECT *self)
+formatter_parser(PyObject *ignored, STRINGLIB_OBJECT *self)
{
formatteriterobject *it;
@@ -1315,7 +1315,7 @@ static PyTypeObject PyFieldNameIter_Type = {
field_name_split. The iterator it returns is a
FieldNameIterator */
static PyObject *
-formatter_field_name_split(STRINGLIB_OBJECT *self)
+formatter_field_name_split(PyObject *ignored, STRINGLIB_OBJECT *self)
{
SubString first;
Py_ssize_t first_idx;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 37a9070..a18eeef 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8968,8 +8968,6 @@ static PyMethodDef unicode_methods[] = {
{"zfill", (PyCFunction) unicode_zfill, METH_VARARGS, zfill__doc__},
{"format", (PyCFunction) do_string_format, METH_VARARGS | METH_KEYWORDS, format__doc__},
{"__format__", (PyCFunction) unicode__format__, METH_VARARGS, p_format__doc__},
- {"_formatter_field_name_split", (PyCFunction) formatter_field_name_split, METH_NOARGS},
- {"_formatter_parser", (PyCFunction) formatter_parser, METH_NOARGS},
{"maketrans", (PyCFunction) unicode_maketrans,
METH_VARARGS | METH_STATIC, maketrans__doc__},
{"__sizeof__", (PyCFunction) unicode__sizeof__, METH_NOARGS, sizeof__doc__},
@@ -10170,6 +10168,36 @@ PyUnicode_AsUnicodeCopy(PyObject *object)
return copy;
}
+/* A _string module, to export formatter_parser and formatter_field_name_split
+ to the string.Formatter class implemented in Python. */
+
+static PyMethodDef _string_methods[] = {
+ {"formatter_field_name_split", (PyCFunction) formatter_field_name_split,
+ METH_O, PyDoc_STR("split the argument as a field name")},
+ {"formatter_parser", (PyCFunction) formatter_parser,
+ METH_O, PyDoc_STR("parse the argument as a format string")},
+ {NULL, NULL}
+};
+
+static struct PyModuleDef _string_module = {
+ PyModuleDef_HEAD_INIT,
+ "_string",
+ PyDoc_STR("string helper module"),
+ 0,
+ _string_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit__string(void)
+{
+ return PyModule_Create(&_string_module);
+}
+
+
#ifdef __cplusplus
}
#endif