+ result = PyUnicode_New(slicelength, PyUnicode_MAX_CHAR_VALUE(self));
This is incorrect: the maxchar of the slice might be smaller than the maxchar of the input string. So you'll need to iterate over the input string first, compute the maxchar, and then allocate the result string.
Or you allocate a temporary buffer of (1<<(kind-1)) * slicelength bytes, copy the slice, allocate the target object with PyUnicode_FromKindAndData, and release the temporary buffer. Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com