Georg Brandl wrote:
> In string_replace, there is
> 
>       if (PyString_Check(from)) {
>         /* Can this be made a '!check' after the Unicode check? */
>       }
> #ifdef Py_USING_UNICODE
>       if (PyUnicode_Check(from))
>               return PyUnicode_Replace((PyObject *)self,
>                                        from, to, count);
> #endif
>       else if (PyObject_AsCharBuffer(from, &tmp_s, &tmp_len))
>               return NULL;
> 
> [the same check with "to"]
> 
>       return (PyObject *)replace((PyStringObject *) self,
>                                  (PyStringObject *) from,
>                                  (PyStringObject *) to, count);
> 
> 
> Can this be correct if from or to isn't a string object, but a
> char buffer compatible object?

Certainly not :-)

Also note that tmp_s and tmp_len are no longer used in the
function.

It appears as if there's some code missing from the function
(and that there's no unit which actually does a string
replace with non-string objects).

Since replace() only works on string objects, it appears
as if a temporary string object would have to be created.
However, this would involve an unnecessary allocation
and copy process... it appears as if the refactoring
during the NFS sprint left out that case.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jun 16 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to