On Nov 21, 2007 6:55 PM, amaury.forgeotdarc
<[email protected]> wrote:
> Author: amaury.forgeotdarc
> Date: Thu Nov 22 03:55:35 2007
> New Revision: 59110
>
> Modified:
>    python/branches/py3k/Objects/stringobject.c
> Log:
> Typo in bytes.replace(): the buffer interface was always used.
>
>
> Modified: python/branches/py3k/Objects/stringobject.c
> ==============================================================================
> --- python/branches/py3k/Objects/stringobject.c (original)
> +++ python/branches/py3k/Objects/stringobject.c Thu Nov 22 03:55:35 2007
> @@ -2594,7 +2594,7 @@
>                 from_s = PyString_AS_STRING(from);
>                 from_len = PyString_GET_SIZE(from);
>         }
> -       if (PyUnicode_Check(from))
> +       else if (PyUnicode_Check(from))
>                 return PyUnicode_Replace((PyObject *)self,
>                                          from, to, count);
>         else if (PyObject_AsCharBuffer(from, &from_s, &from_len))

Actually, all those fallbacks to PyUnicode should be removed from
stringobject.c. And PyUnicode methods should not accept PyString
instances as arguments. This will probably require adjusting some more
unittests (and perhaps other modules) that were so far getting away
with illegal things...

And it's find to change the PyString to always use the buffer API for
its arguments -- in theory using PyString_AS_STRING and
PyString_GET_SIZE will be a tiny bit faster, but it's also more code,
and I favor less code unless a particular method is identified as a
performance hog.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to