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

Unified Diff: Modules/_testcapimodule.c

Issue 28822: Fix indices handling in PyUnicode_FindChar
Patch Set: Created 2 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
--- a/Modules/_testcapimodule.c Tue Nov 29 09:56:07 2016 +0200
+++ b/Modules/_testcapimodule.c Tue Nov 29 23:46:20 2016 +0800
@@ -1875,6 +1875,27 @@
}
static PyObject *
+unicode_findchar(PyObject *self, PyObject *args)
+{
+ PyObject *str;
+ int direction;
+ unsigned int ch;
+ Py_ssize_t result;
+ Py_ssize_t start, end;
+
+ if (!PyArg_ParseTuple(args, "UInni:unicode_findchar", &str, &ch,
+ &start, &end, &direction)) {
+ return NULL;
+ }
+
+ result = PyUnicode_FindChar(str, (Py_UCS4)ch, start, end, direction);
+ if (result == -2)
+ return NULL;
+ else
+ return PyLong_FromSsize_t(result);
+}
+
+static PyObject *
unicode_copycharacters(PyObject *self, PyObject *args)
{
PyObject *from, *to, *to_copy;
@@ -4107,6 +4128,7 @@
{"unicode_aswidechar", unicode_aswidechar, METH_VARARGS},
{"unicode_aswidecharstring",unicode_aswidecharstring, METH_VARARGS},
{"unicode_asucs4", unicode_asucs4, METH_VARARGS},
+ {"unicode_findchar", unicode_findchar, METH_VARARGS},
{"unicode_copycharacters", unicode_copycharacters, METH_VARARGS},
{"unicode_encodedecimal", unicode_encodedecimal, METH_VARARGS},
{"unicode_transformdecimaltoascii", unicode_transformdecimaltoascii, METH_VARARGS},

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