diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-18 19:35:23 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-18 19:35:23 (GMT) |
commit | 9cd177526afc086a300b548588880329c32f607d (patch) | |
tree | e842c29c3f11a1bcd885863fa8ea90e40f155bc8 /Objects/unicodeobject.c | |
parent | 81ca7c784c4dd58dde691284321e3e220550a75c (diff) | |
download | cpython-9cd177526afc086a300b548588880329c32f607d.zip cpython-9cd177526afc086a300b548588880329c32f607d.tar.gz cpython-9cd177526afc086a300b548588880329c32f607d.tar.bz2 |
Merged revisions 59005-59040 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
I've tried to fix test_cmd_line_script but I wasn't able to get all tests
right. Nick, can you please have a look?
........
r59020 | facundo.batista | 2007-11-16 19:04:14 +0100 (Fri, 16 Nov 2007) | 12 lines
Now in find, rfind, index, and rindex, you can use None as defaults,
as usual with slicing (both with str and unicode strings). This
fixes issue 1259.
For str only the stringobject.c file was modified. But for unicode,
I needed to repeat in the four functions a lot of code, so created
a new function that does part of the job for them (and placed it in
find.h, following a suggestion of Barry).
Also added tests for this behaviour.
........
r59021 | facundo.batista | 2007-11-16 19:41:24 +0100 (Fri, 16 Nov 2007) | 4 lines
Fix for stupid error (I need to remember to do a full 'make clean + make'
cycle before the tests...). Sorry.
........
r59022 | facundo.batista | 2007-11-16 20:16:15 +0100 (Fri, 16 Nov 2007) | 3 lines
Made _ParseTupleFinds only defined to unicodeobject.c
........
r59024 | raymond.hettinger | 2007-11-17 02:51:22 +0100 (Sat, 17 Nov 2007) | 1 line
Fix signature in example
........
r59033 | brett.cannon | 2007-11-17 08:07:29 +0100 (Sat, 17 Nov 2007) | 5 lines
Remove a confusing sentence about pth files and which directories are searched
for them.
Closes issue #1431. Thanks Giambattista Bloisi for the help.
........
r59039 | nick.coghlan | 2007-11-18 12:56:28 +0100 (Sun, 18 Nov 2007) | 1 line
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
........
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index a011a9a..426dc07 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5096,10 +5096,10 @@ int PyUnicode_EncodeDecimal(Py_UNICODE *s, /* --- Helpers ------------------------------------------------------------ */ #include "stringlib/unicodedefs.h" - #include "stringlib/fastsearch.h" - #include "stringlib/count.h" +/* Include _ParseTupleFinds from find.h */ +#define FROM_UNICODE #include "stringlib/find.h" #include "stringlib/partition.h" @@ -6590,16 +6590,12 @@ static PyObject * unicode_find(PyUnicodeObject *self, PyObject *args) { PyObject *substring; - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; + Py_ssize_t start; + Py_ssize_t end; Py_ssize_t result; - if (!PyArg_ParseTuple(args, "O|O&O&:find", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) + if (!_ParseTupleFinds(args, &substring, &start, &end)) return NULL; - substring = PyUnicode_FromObject(substring); - if (!substring) - return NULL; result = stringlib_find_slice( PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), @@ -6656,15 +6652,11 @@ unicode_index(PyUnicodeObject *self, PyObject *args) { Py_ssize_t result; PyObject *substring; - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; + Py_ssize_t start; + Py_ssize_t end; - if (!PyArg_ParseTuple(args, "O|O&O&:index", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) + if (!_ParseTupleFinds(args, &substring, &start, &end)) return NULL; - substring = PyUnicode_FromObject(substring); - if (!substring) - return NULL; result = stringlib_find_slice( PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), @@ -7499,16 +7491,12 @@ static PyObject * unicode_rfind(PyUnicodeObject *self, PyObject *args) { PyObject *substring; - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; + Py_ssize_t start; + Py_ssize_t end; Py_ssize_t result; - if (!PyArg_ParseTuple(args, "O|O&O&:rfind", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = PyUnicode_FromObject(substring); - if (!substring) - return NULL; + if (!_ParseTupleFinds(args, &substring, &start, &end)) + return NULL; result = stringlib_rfind_slice( PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), @@ -7530,16 +7518,12 @@ static PyObject * unicode_rindex(PyUnicodeObject *self, PyObject *args) { PyObject *substring; - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; + Py_ssize_t start; + Py_ssize_t end; Py_ssize_t result; - if (!PyArg_ParseTuple(args, "O|O&O&:rindex", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = PyUnicode_FromObject(substring); - if (!substring) - return NULL; + if (!_ParseTupleFinds(args, &substring, &start, &end)) + return NULL; result = stringlib_rfind_slice( PyUnicode_AS_UNICODE(self), PyUnicode_GET_SIZE(self), |