return
self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize)
+ def test_expandtabs_optimization(self):
+ s = 'abc'
+ self.assertIs(s.expandtabs(), s)
+
def test_raiseMemError(self):
if struct.calcsize('P') == 8:
# 64 bits pointers
void *src_data, *dest_data;
int tabsize = 8;
int kind;
+ int found;
if (!PyArg_ParseTuple(args, "|i:expandtabs", &tabsize))
return NULL;
i = j = line_pos = 0;
kind = PyUnicode_KIND(self);
src_data = PyUnicode_DATA(self);
+ found = 0;
for (; i < src_len; i++) {
ch = PyUnicode_READ(kind, src_data, i);
if (ch == '\t') {
+ found = 1;
if (tabsize > 0) {
incr = tabsize - (line_pos % tabsize); /* cannot overflow */
if (j > PY_SSIZE_T_MAX - incr)
line_pos = 0;
}
}
+ if (!found && PyUnicode_CheckExact(self)) {
+ Py_INCREF((PyObject *) self);
+ return (PyObject *) self;
+ }
/* Second pass: create output string and fill it */
u = PyUnicode_New(j, PyUnicode_MAX_CHAR_VALUE(self));