[Python-checkins] cpython: PyUnicode_FromObject() reuses PyUnicode_Copy()
victor.stinner
python-checkins at python.org
Sat Oct 1 02:49:27 CEST 2011
http://hg.python.org/cpython/rev/d94b0b371878
changeset: 72549:d94b0b371878
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Sat Oct 01 01:16:59 2011 +0200
summary:
PyUnicode_FromObject() reuses PyUnicode_Copy()
* PyUnicode_Copy() is faster than substring()
* Fix also a compiler warning
files:
Objects/unicodeobject.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2052,9 +2052,7 @@
if (PyUnicode_Check(obj)) {
/* For a Unicode subtype that's not a Unicode object,
return a true Unicode object with the same data. */
- if (PyUnicode_READY(obj) == -1)
- return NULL;
- return substring((PyUnicodeObject *)obj, 0, PyUnicode_GET_LENGTH(obj));
+ return PyUnicode_Copy(obj);
}
PyErr_Format(PyExc_TypeError,
"Can't convert '%.100s' object to str implicitly",
@@ -11465,7 +11463,7 @@
return (PyObject*) self;
}
else
- return PyUnicode_Copy(self);
+ return PyUnicode_Copy((PyObject*)self);
}
fill = width - _PyUnicode_LENGTH(self);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list