Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Delta Between Two Patch Sets: Objects/unicodeobject.c

Issue 8706: accept keyword arguments on all base type methods and builtins
Left Patch Set: Created 8 years, 3 months ago
Right Patch Set: Created 8 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Objects/stringlib/find.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 2
3 Unicode implementation based on original code by Fredrik Lundh, 3 Unicode implementation based on original code by Fredrik Lundh,
4 modified by Marc-Andre Lemburg <mal@lemburg.com>. 4 modified by Marc-Andre Lemburg <mal@lemburg.com>.
5 5
6 Major speed upgrades to the method implementations at the Reykjavik 6 Major speed upgrades to the method implementations at the Reykjavik
7 NeedForSpeed sprint, by Fredrik Lundh and Andrew Dalke. 7 NeedForSpeed sprint, by Fredrik Lundh and Andrew Dalke.
8 8
9 Copyright (c) Corporation for National Research Initiatives. 9 Copyright (c) Corporation for National Research Initiatives.
10 10
(...skipping 12481 matching lines...) Expand 10 before | Expand all | Expand 10 after
12492 } 12492 }
12493 12493
12494 result = split(s, sep, maxsplit); 12494 result = split(s, sep, maxsplit);
12495 12495
12496 Py_DECREF(s); 12496 Py_DECREF(s);
12497 Py_XDECREF(sep); 12497 Py_XDECREF(sep);
12498 return result; 12498 return result;
12499 } 12499 }
12500 12500
12501 PyDoc_STRVAR(split__doc__, 12501 PyDoc_STRVAR(split__doc__,
12502 "S.split([sep[, maxsplit]]) -> list of strings\n\ 12502 "S.split(sep=None, maxsplit=-1) -> list of strings\n\
12503 \n\ 12503 \n\
12504 Return a list of the words in S, using sep as the\n\ 12504 Return a list of the words in S, using sep as the\n\
12505 delimiter string. If maxsplit is given, at most maxsplit\n\ 12505 delimiter string. If maxsplit is given, at most maxsplit\n\
12506 splits are done. If sep is not specified or is None, any\n\ 12506 splits are done. If sep is not specified or is None, any\n\
12507 whitespace string is a separator and empty strings are\n\ 12507 whitespace string is a separator and empty strings are\n\
12508 removed from the result."); 12508 removed from the result.");
12509 12509
12510 static PyObject* 12510 static PyObject*
12511 unicode_split(PyObject *self, PyObject *args) 12511 unicode_split(PyObject *self, PyObject *args, PyObject *kwds)
12512 { 12512 {
12513 static char *kwlist[] = {"sep", "maxsplit", 0};
12513 PyObject *substring = Py_None; 12514 PyObject *substring = Py_None;
12514 Py_ssize_t maxcount = -1; 12515 Py_ssize_t maxcount = -1;
12515 12516
12516 if (!PyArg_ParseTuple(args, "|On:split", &substring, &maxcount)) 12517 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|On:split",
12518 kwlist, &substring, &maxcount))
12517 return NULL; 12519 return NULL;
12518 12520
12519 if (substring == Py_None) 12521 if (substring == Py_None)
12520 return split(self, NULL, maxcount); 12522 return split(self, NULL, maxcount);
12521 else if (PyUnicode_Check(substring)) 12523 else if (PyUnicode_Check(substring))
12522 return split(self, substring, maxcount); 12524 return split(self, substring, maxcount);
12523 else 12525 else
12524 return PyUnicode_Split(self, substring, maxcount); 12526 return PyUnicode_Split(self, substring, maxcount);
12525 } 12527 }
12526 12528
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
12715 } 12717 }
12716 12718
12717 result = rsplit(s, sep, maxsplit); 12719 result = rsplit(s, sep, maxsplit);
12718 12720
12719 Py_DECREF(s); 12721 Py_DECREF(s);
12720 Py_XDECREF(sep); 12722 Py_XDECREF(sep);
12721 return result; 12723 return result;
12722 } 12724 }
12723 12725
12724 PyDoc_STRVAR(rsplit__doc__, 12726 PyDoc_STRVAR(rsplit__doc__,
12725 "S.rsplit([sep[, maxsplit]]) -> list of strings\n\ 12727 "S.rsplit(sep=None, maxsplit=-1) -> list of strings\n\
12726 \n\ 12728 \n\
12727 Return a list of the words in S, using sep as the\n\ 12729 Return a list of the words in S, using sep as the\n\
12728 delimiter string, starting at the end of the string and\n\ 12730 delimiter string, starting at the end of the string and\n\
12729 working to the front. If maxsplit is given, at most maxsplit\n\ 12731 working to the front. If maxsplit is given, at most maxsplit\n\
12730 splits are done. If sep is not specified, any whitespace string\n\ 12732 splits are done. If sep is not specified, any whitespace string\n\
12731 is a separator."); 12733 is a separator.");
12732 12734
12733 static PyObject* 12735 static PyObject*
12734 unicode_rsplit(PyObject *self, PyObject *args) 12736 unicode_rsplit(PyObject *self, PyObject *args, PyObject *kwds)
12735 { 12737 {
12738 static char *kwlist[] = {"sep", "maxsplit", 0};
12736 PyObject *substring = Py_None; 12739 PyObject *substring = Py_None;
12737 Py_ssize_t maxcount = -1; 12740 Py_ssize_t maxcount = -1;
12738 12741
12739 if (!PyArg_ParseTuple(args, "|On:rsplit", &substring, &maxcount)) 12742 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|On:rsplit",
12743 kwlist, &substring, &maxcount))
12740 return NULL; 12744 return NULL;
12741 12745
12742 if (substring == Py_None) 12746 if (substring == Py_None)
12743 return rsplit(self, NULL, maxcount); 12747 return rsplit(self, NULL, maxcount);
12744 else if (PyUnicode_Check(substring)) 12748 else if (PyUnicode_Check(substring))
12745 return rsplit(self, substring, maxcount); 12749 return rsplit(self, substring, maxcount);
12746 else 12750 else
12747 return PyUnicode_RSplit(self, substring, maxcount); 12751 return PyUnicode_RSplit(self, substring, maxcount);
12748 } 12752 }
12749 12753
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
13160 return Py_BuildValue("(N)", copy); 13164 return Py_BuildValue("(N)", copy);
13161 } 13165 }
13162 13166
13163 static PyMethodDef unicode_methods[] = { 13167 static PyMethodDef unicode_methods[] = {
13164 13168
13165 /* Order is according to common usage: often used methods should 13169 /* Order is according to common usage: often used methods should
13166 appear first, since lookup is done sequentially. */ 13170 appear first, since lookup is done sequentially. */
13167 13171
13168 {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encod e__doc__}, 13172 {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encod e__doc__},
13169 {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, 13173 {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__},
13170 {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__}, 13174 {"split", (PyCFunction) unicode_split, METH_VARARGS | METH_KEYWORDS, split__ doc__},
13171 {"rsplit", (PyCFunction) unicode_rsplit, METH_VARARGS, rsplit__doc__}, 13175 {"rsplit", (PyCFunction) unicode_rsplit, METH_VARARGS | METH_KEYWORDS, rspli t__doc__},
13172 {"join", (PyCFunction) unicode_join, METH_O, join__doc__}, 13176 {"join", (PyCFunction) unicode_join, METH_O, join__doc__},
13173 {"capitalize", (PyCFunction) unicode_capitalize, METH_NOARGS, capitalize__do c__}, 13177 {"capitalize", (PyCFunction) unicode_capitalize, METH_NOARGS, capitalize__do c__},
13174 {"casefold", (PyCFunction) unicode_casefold, METH_NOARGS, casefold__doc__}, 13178 {"casefold", (PyCFunction) unicode_casefold, METH_NOARGS, casefold__doc__},
13175 {"title", (PyCFunction) unicode_title, METH_NOARGS, title__doc__}, 13179 {"title", (PyCFunction) unicode_title, METH_NOARGS, title__doc__},
13176 {"center", (PyCFunction) unicode_center, METH_VARARGS, center__doc__}, 13180 {"center", (PyCFunction) unicode_center, METH_VARARGS, center__doc__},
13177 {"count", (PyCFunction) unicode_count, METH_VARARGS | METH_KEYWORDS, count__ doc__}, 13181 {"count", (PyCFunction) unicode_count, METH_VARARGS | METH_KEYWORDS, count__ doc__},
13178 {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__d oc__}, 13182 {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__d oc__},
13179 {"find", (PyCFunction) unicode_find, METH_VARARGS | METH_KEYWORDS, find__doc __}, 13183 {"find", (PyCFunction) unicode_find, METH_VARARGS | METH_KEYWORDS, find__doc __},
13180 {"partition", (PyCFunction) unicode_partition, METH_O, partition__doc__}, 13184 {"partition", (PyCFunction) unicode_partition, METH_O, partition__doc__},
13181 {"index", (PyCFunction) unicode_index, METH_VARARGS | METH_KEYWORDS, index__ doc__}, 13185 {"index", (PyCFunction) unicode_index, METH_VARARGS | METH_KEYWORDS, index__ doc__},
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
14580 PyMODINIT_FUNC 14584 PyMODINIT_FUNC
14581 PyInit__string(void) 14585 PyInit__string(void)
14582 { 14586 {
14583 return PyModule_Create(&_string_module); 14587 return PyModule_Create(&_string_module);
14584 } 14588 }
14585 14589
14586 14590
14587 #ifdef __cplusplus 14591 #ifdef __cplusplus
14588 } 14592 }
14589 #endif 14593 #endif
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+