Serhiy Storchaka added the comment:

> Isn’t there a “Unicode writer” API that could be used?

It could be used if accumulate only Python strings, C strings and separate 
characters. But in any case we need to convert C integers to strings, and add 
up to 3 items per every attribute (separator, name, value), the result of every 
addition should be checked. PyUnicode_FromFormat() is an easy way to 
concatenate several items. It needs only one check.

> The annoying part is to handle the ", " separator. I also had bad experiences 
> with handling char* strings. It's so easy to make mistakes :-(

It could be simpler if use the trick with the sep variable. As for mistakes, 
actually that version of Utkarsh's patch was less buggy than the few following 
versions using the Python C API. But the final C code is correct and LGTM.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to