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

Delta Between Two Patch Sets: Modules/_testcapimodule.c

Issue 28822: Fix indices handling in PyUnicode_FindChar
Left Patch Set: Created 2 years, 8 months ago
Right Patch Set: Created 2 years, 8 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
LEFTRIGHT
1 /* 1 /*
2 * C Extension module to test Python interpreter C APIs. 2 * C Extension module to test Python interpreter C APIs.
3 * 3 *
4 * The 'test_*' functions exported by this module are run as part of the 4 * The 'test_*' functions exported by this module are run as part of the
5 * standard Python regression test, via Lib/test/test_capi.py. 5 * standard Python regression test, via Lib/test/test_capi.py.
6 */ 6 */
7 7
8 #define PY_SSIZE_T_CLEAN 8 #define PY_SSIZE_T_CLEAN
9 9
10 #include "Python.h" 10 #include "Python.h"
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 1871
1872 result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len); 1872 result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
1873 PyMem_FREE(buffer); 1873 PyMem_FREE(buffer);
1874 return result; 1874 return result;
1875 } 1875 }
1876 1876
1877 static PyObject * 1877 static PyObject *
1878 unicode_findchar(PyObject *self, PyObject *args) 1878 unicode_findchar(PyObject *self, PyObject *args)
1879 { 1879 {
1880 PyObject *str; 1880 PyObject *str;
1881 int ch, direction; 1881 int direction;
1882 unsigned int ch;
1882 Py_ssize_t result; 1883 Py_ssize_t result;
1883 Py_ssize_t start, end; 1884 Py_ssize_t start, end;
1884 1885
1885 if (!PyArg_ParseTuple(args, "UCnni:unicode_findchar", &str, &ch, 1886 if (!PyArg_ParseTuple(args, "UInni:unicode_findchar", &str, &ch,
1886 &start, &end, &direction)) { 1887 &start, &end, &direction)) {
1887 return NULL; 1888 return NULL;
1888 } 1889 }
1889 1890
1890 result = PyUnicode_FindChar(str, (Py_UCS4)ch, start, end, direction); 1891 result = PyUnicode_FindChar(str, (Py_UCS4)ch, start, end, direction);
1891 if (result == -2) 1892 if (result == -2)
1892 return NULL; 1893 return NULL;
1893 else 1894 else
1894 return PyLong_FromSsize_t(result); 1895 return PyLong_FromSsize_t(result);
1895 } 1896 }
(...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after
4639 Py_INCREF(&PyInstanceMethod_Type); 4640 Py_INCREF(&PyInstanceMethod_Type);
4640 PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type); 4641 PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);
4641 4642
4642 PyModule_AddIntConstant(m, "the_number_three", 3); 4643 PyModule_AddIntConstant(m, "the_number_three", 3);
4643 4644
4644 TestError = PyErr_NewException("_testcapi.error", NULL, NULL); 4645 TestError = PyErr_NewException("_testcapi.error", NULL, NULL);
4645 Py_INCREF(TestError); 4646 Py_INCREF(TestError);
4646 PyModule_AddObject(m, "error", TestError); 4647 PyModule_AddObject(m, "error", TestError);
4647 return m; 4648 return m;
4648 } 4649 }
LEFTRIGHT

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