bpo-36365: Rewrite structseq_repr() using _PyUnicodeWriter by vstinner · Pull Request #12440 · python/cpython

Conversation

@vstinner

No longer limit repr(structseq) to 512 bytes. Use _PyUnicodeWriter
for better performance and write directly Unicode rather than using
encode repr() value to UTF-8 and then decode from UTF-8.

https://bugs.python.org/issue36365

No longer limit repr(structseq) to 512 bytes. Use _PyUnicodeWriter
for better performance and write directly Unicode rather than using
encode repr() value to UTF-8 and then decode from UTF-8.

ZackerySpytz

strlen(typ->tp_name),
NULL);
if (type_name == NULL) {
goto error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, this goto error would cause _PyUnicodeWriter_Dealloc() to be called on an uninitialized _PyUnicodeWriter. This was fixed in 93e8012.

@vstinner

For the record, this goto error would cause _PyUnicodeWriter_Dealloc() to be called on an uninitialized _PyUnicodeWriter. This was fixed in 93e8012.

Oops, I moved "PyObject *type_name = ..." after my initial code to simplify the error handling, but I forgot to make the error handling correct in the final change. So thanks for the fix!