[ python-Bugs-1515471 ] wrong handling of character buffers in stringobject

SourceForge.net noreply at sourceforge.net
Thu Jul 27 06:38:37 CEST 2006


Bugs item #1515471, was opened at 2006-07-01 02:41
Message generated for change (Settings changed) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1515471&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
>Priority: 9
Submitted By: Georg Brandl (gbrandl)
Assigned to: Fredrik Lundh (effbot)
Summary: wrong handling of character buffers in stringobject

Initial Comment:
stringobject.c:

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);

This is not correct if from or to isn't a string
object, but a char buffer compatible object.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1515471&group_id=5470


More information about the Python-bugs-list mailing list