summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index ebf8c42..1e8f63f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8096,6 +8096,12 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
if (slicelength <= 0) {
return PyUnicode_FromUnicode(NULL, 0);
+ } else if (start == 0 && step == 1 && slicelength == self->length &&
+ PyUnicode_CheckExact(self)) {
+ Py_INCREF(self);
+ return (PyObject *)self;
+ } else if (step == 1) {
+ return PyUnicode_FromUnicode(self->str + start, slicelength);
} else {
source_buf = PyUnicode_AS_UNICODE((PyObject*)self);
result_buf = (Py_UNICODE *)PyMem_MALLOC(slicelength*