[Python-Dev] Bug in stringobject? (original) (raw)
M.-A. Lemburg mal at egenix.com
Fri Jun 16 15:07:07 CEST 2006
- Previous message: [Python-Dev] Bug in stringobject?
- Next message: [Python-Dev] Bug in stringobject?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Georg Brandl wrote:
In stringreplace, there is
if (PyStringCheck(from)) { /* Can this be made a '!check' after the Unicode check? */ } #ifdef PyUSINGUNICODE if (PyUnicodeCheck(from)) return PyUnicodeReplace((PyObject *)self, from, to, count); #endif else if (PyObjectAsCharBuffer(from, &tmps, &tmplen)) 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 ! ::::
- Previous message: [Python-Dev] Bug in stringobject?
- Next message: [Python-Dev] Bug in stringobject?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]