[Python-Dev] Re: [Bug #115845] sre: maxsplit as keyword argument

Guido van Rossum guido@python.org
Mon, 02 Oct 2000 15:18:57 -0500


> http://sourceforge.net/bugs/?func=detailbug&bug_id=115845&group_id=5470
> 
> > Details: Split gives TypeError when called as a method of compiled
> > regular expression object with maxsplit as keyword argument.
> > This error is only in sre, pre is OK.
> > 
> > Python 1.6 (#2, Sep  6 2000, 18:20:07) [C] on osf1V4
> > >>> import re
> > >>> patt = re.compile(' ')
> > >>> list = patt.split("a b c",50)              # OK
> > >>> list = re.split(' ',"a b c",maxsplit=50)   # OK     
> > >>> list = patt.split("a b c",maxsplit=50)     # ERROR
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > TypeError: this function takes no keyword arguments
> > 
> > >>> import pre
> > >>> patt = pre.compile(' ')
> > >>> list = patt.split("a b c",maxsplit=50)     # OK
> 
> is this really a bug?  should users expect to be able to use
> keyword arguments anywhere?

Unclear, but the names were documented, and it worked before (when
pattern objects were Python instances) -- so who knows how much code
there's lying around that assumes this.  Well, we know it's more than
zero, because the bug report came from soemone who ran into this. :-)

Can we at PythonLabs help by adding keyword arguments to all of the
_sre.c functions?  I presume it's a pretty straightforward change.

--Guido van Rossum (home page: http://www.python.org/~guido/)