[Python-Dev] None in arguments to "".find and family of functions

Facundo Batista facundobatista at gmail.com
Thu Nov 1 19:09:56 CET 2007


Hello people!

I'm following the issue 1259 (http://bugs.python.org/issue1259)

It basically says that this should be ok: "'asd'.find('s', None,
None)", as the documentation says that "start" and "end" arguments
behaves like in slices (right now it gives a TypeError).

I created a patch, that solves the problem presented in that patch, as
is suggested by Barry A. Warsaw.

The patch touches three files:

- Lib/test/string_tests.py: The test cases for this.

- Objects/stringobject.c: Here I modified the string_find_internal()
function, for PyArg_ParseTuple to not call directly to
PyEval_SliceIndex: I just call it if the function received an argument
and is not None.

- Objects/unicodeobject.c: Here I needed to make the same in
unicode_find(), unicode_rfind(), unicode_index(), and
unicode_rindex(), so I created another function called
_ParseTupleFinds(), for this family of functions, which handles the
arguments and returns the needed info for each function.


All the tests pass ok, I'm sending this mail to see if anybody could
please review the patch before I apply it, as this is the first patch
that I create in C. Feel free to ignore this mail if the patch is ok,
:)

Regards,


-- 

.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


More information about the Python-Dev mailing list