bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)

https://bugs.python.org/issue46765
This commit is contained in:
Eric Snow 2022-02-22 17:23:51 -07:00 committed by GitHub
parent cff4d5c5d2
commit 1f455361ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 192 additions and 526 deletions

View file

@ -192,7 +192,7 @@ write_str(stringio *self, PyObject *obj)
}
if (self->writenl) {
PyObject *translated = PyUnicode_Replace(
decoded, _PyIO_str_nl, self->writenl, -1);
decoded, &_Py_STR(newline), self->writenl, -1);
Py_DECREF(decoded);
decoded = translated;
}
@ -409,7 +409,7 @@ stringio_iternext(stringio *self)
else {
/* XXX is subclassing StringIO really supported? */
line = PyObject_CallMethodNoArgs((PyObject *)self,
_PyIO_str_readline);
&_Py_ID(readline));
if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_OSError,
"readline() should have returned a str object, "
@ -964,7 +964,7 @@ stringio_newlines(stringio *self, void *context)
CHECK_CLOSED(self);
if (self->decoder == NULL)
Py_RETURN_NONE;
return PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
return PyObject_GetAttr(self->decoder, &_Py_ID(newlines));
}
#include "clinic/stringio.c.h"